occam-verify-cli 0.0.470 → 0.0.472
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/constants.js +4 -8
- package/lib/context/file.js +9 -9
- package/lib/context/metaproof.js +38 -32
- package/lib/context/proof.js +35 -29
- package/lib/equality.js +22 -0
- package/lib/metaSubstitution.js +12 -52
- package/lib/rule.js +15 -19
- package/lib/step/metaproof.js +114 -0
- package/lib/step/proof.js +68 -0
- package/lib/substitution.js +16 -56
- package/lib/utilities/array.js +2 -5
- package/lib/utilities/node.js +105 -0
- package/lib/verify/antecedent.js +4 -4
- package/lib/verify/derivation.js +16 -18
- package/lib/verify/equality.js +18 -5
- package/lib/verify/metaDerivation.js +16 -18
- package/lib/verify/metaproof.js +10 -51
- package/lib/verify/metastatement/qualified.js +1 -7
- package/lib/verify/metastatement/unqualified.js +2 -9
- package/lib/verify/premiseOrPremises.js +4 -4
- package/lib/verify/proof.js +11 -52
- package/lib/verify/statement/qualified.js +1 -7
- package/lib/verify/statement/unqualified.js +2 -9
- package/package.json +1 -1
- package/src/constants.js +1 -2
- package/src/context/file.js +6 -6
- package/src/context/metaproof.js +32 -31
- package/src/context/proof.js +30 -29
- package/src/equality.js +8 -0
- package/src/metaSubstitution.js +16 -87
- package/src/rule.js +19 -26
- package/src/step/metaproof.js +99 -0
- package/src/step/proof.js +30 -0
- package/src/substitution.js +19 -90
- package/src/utilities/array.js +1 -1
- package/src/utilities/node.js +149 -0
- package/src/verify/antecedent.js +3 -3
- package/src/verify/derivation.js +17 -18
- package/src/verify/equality.js +29 -11
- package/src/verify/metaDerivation.js +17 -18
- package/src/verify/metaproof.js +20 -91
- package/src/verify/metastatement/qualified.js +0 -9
- package/src/verify/metastatement/unqualified.js +1 -12
- package/src/verify/premiseOrPremises.js +3 -3
- package/src/verify/proof.js +21 -92
- package/src/verify/statement/qualified.js +0 -9
- package/src/verify/statement/unqualified.js +1 -13
- package/lib/assertion.js +0 -147
- package/lib/metaAssertion.js +0 -200
- package/lib/utilities/metastatement.js +0 -45
- package/lib/utilities/statement.js +0 -45
- package/src/assertion.js +0 -150
- package/src/metaAssertion.js +0 -245
- package/src/utilities/metastatement.js +0 -50
- package/src/utilities/statement.js +0 -50
package/src/context/metaproof.js
CHANGED
|
@@ -7,10 +7,10 @@ import callbacksMixins from "../mixins/callbacks";
|
|
|
7
7
|
import { last } from "../utilities/array";
|
|
8
8
|
|
|
9
9
|
class MetaproofContext {
|
|
10
|
-
constructor(context, derived,
|
|
10
|
+
constructor(context, derived, metaproofSteps) {
|
|
11
11
|
this.context = context;
|
|
12
12
|
this.derived = derived;
|
|
13
|
-
this.
|
|
13
|
+
this.metaproofSteps = metaproofSteps;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
getContext() {
|
|
@@ -21,63 +21,64 @@ class MetaproofContext {
|
|
|
21
21
|
return this.derived;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
let
|
|
24
|
+
getMetaproofSteps() {
|
|
25
|
+
let metaproofSteps = this.context.getMetaproofSteps();
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
...
|
|
29
|
-
...this.
|
|
27
|
+
metaproofSteps = [ ///
|
|
28
|
+
...metaproofSteps,
|
|
29
|
+
...this.metaproofSteps
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return metaproofSteps;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
let
|
|
35
|
+
getLastMetaproofStep() {
|
|
36
|
+
let lastMetaproofStep = null;
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const metaproofStepsLength = this.metaproofSteps.length;
|
|
39
39
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
if (metaproofStepsLength > 0) {
|
|
41
|
+
lastMetaproofStep = last(this.metaproofSteps);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
return
|
|
44
|
+
return lastMetaproofStep;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
setDerived(derived) {
|
|
47
|
+
setDerived(derived = true) {
|
|
48
48
|
this.derived = derived;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
this.
|
|
51
|
+
resetDerived() {
|
|
52
|
+
this.derived = false;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
addMetaproofStep(metaproofStep) {
|
|
56
|
+
this.metaproofSteps.push(metaproofStep);
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
matchMetastatement(metastatementNode) {
|
|
60
|
+
let metastatementMatches;
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
matches = metaAssertionA.match(metaAssertionB);
|
|
62
|
+
metastatementMatches = this.metaproofSteps.some((metaproofStep) => {
|
|
63
|
+
metastatementMatches = metaproofStep.matchMetastatement(metastatementNode);
|
|
63
64
|
|
|
64
|
-
if (
|
|
65
|
+
if (metastatementMatches) {
|
|
65
66
|
return true;
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
if (!
|
|
70
|
-
|
|
70
|
+
if (!metastatementMatches) {
|
|
71
|
+
metastatementMatches = this.context.matchMetastatement(metastatementNode);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
return
|
|
74
|
+
return metastatementMatches;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
static fromFileContext(fileContext) {
|
|
77
78
|
const context = fileContext, ///
|
|
78
79
|
derived = false,
|
|
79
|
-
|
|
80
|
-
metaproofContext = new MetaproofContext(context, derived,
|
|
80
|
+
metaproofSteps = [],
|
|
81
|
+
metaproofContext = new MetaproofContext(context, derived, metaproofSteps);
|
|
81
82
|
|
|
82
83
|
return metaproofContext;
|
|
83
84
|
}
|
|
@@ -85,9 +86,9 @@ class MetaproofContext {
|
|
|
85
86
|
static fromMetaproofContext(metaproofContext) {
|
|
86
87
|
const context = metaproofContext, ///
|
|
87
88
|
derived = false,
|
|
88
|
-
|
|
89
|
+
metaproofSteps = [];
|
|
89
90
|
|
|
90
|
-
metaproofContext = new MetaproofContext(context, derived,
|
|
91
|
+
metaproofContext = new MetaproofContext(context, derived, metaproofSteps); ///
|
|
91
92
|
|
|
92
93
|
return metaproofContext;
|
|
93
94
|
}
|
package/src/context/proof.js
CHANGED
|
@@ -7,11 +7,11 @@ import callbacksMixins from "../mixins/callbacks";
|
|
|
7
7
|
import { push, last } from "../utilities/array";
|
|
8
8
|
|
|
9
9
|
class ProofContext {
|
|
10
|
-
constructor(context, derived, variables,
|
|
10
|
+
constructor(context, derived, variables, proofSteps) {
|
|
11
11
|
this.context = context;
|
|
12
12
|
this.derived = derived;
|
|
13
13
|
this.variables = variables;
|
|
14
|
-
this.
|
|
14
|
+
this.proofSteps = proofSteps;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
getContext() {
|
|
@@ -22,15 +22,15 @@ class ProofContext {
|
|
|
22
22
|
return this.derived;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
let
|
|
25
|
+
getProofSteps() {
|
|
26
|
+
let proofSteps = this.context.getProofSteps();
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
...
|
|
30
|
-
...this.
|
|
28
|
+
proofSteps = [
|
|
29
|
+
...proofSteps,
|
|
30
|
+
...this.proofSteps
|
|
31
31
|
];
|
|
32
32
|
|
|
33
|
-
return
|
|
33
|
+
return proofSteps;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
getTypes() { return this.context.getTypes(); }
|
|
@@ -57,43 +57,44 @@ class ProofContext {
|
|
|
57
57
|
return variables;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
const
|
|
60
|
+
getLastProofStep() {
|
|
61
|
+
const lastProofStep = last(this.proofSteps);
|
|
62
62
|
|
|
63
|
-
return
|
|
63
|
+
return lastProofStep;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
setDerived(derived) {
|
|
66
|
+
setDerived(derived = true) {
|
|
67
67
|
this.derived = derived;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
resetDerived() {
|
|
71
|
+
this.derived = false;
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
addVariable(variable) {
|
|
71
75
|
this.variables.push(variable);
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
this.
|
|
78
|
+
addProofStep(proofStep) {
|
|
79
|
+
this.proofSteps.push(proofStep);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
let
|
|
80
|
-
|
|
81
|
-
const assertionB = assertion; ///
|
|
82
|
+
matchStatement(statementNode) {
|
|
83
|
+
let statementMatches;
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
matches = assertionA.match(assertionB);
|
|
85
|
+
statementMatches = this.proofSteps.some((proofStep) => {
|
|
86
|
+
statementMatches = proofStep.matchStatement(statementNode);
|
|
86
87
|
|
|
87
|
-
if (
|
|
88
|
+
if (statementMatches) {
|
|
88
89
|
return true;
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
92
|
|
|
92
|
-
if (!
|
|
93
|
-
|
|
93
|
+
if (!statementMatches) {
|
|
94
|
+
statementMatches = this.context.matchStatement(statementNode);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
return
|
|
97
|
+
return statementMatches;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
findVariableByVariableName(variableName) {
|
|
@@ -137,8 +138,8 @@ class ProofContext {
|
|
|
137
138
|
const context = fileContext, ///
|
|
138
139
|
derived = false,
|
|
139
140
|
variables = [],
|
|
140
|
-
|
|
141
|
-
proofContext = new ProofContext(context, derived, variables,
|
|
141
|
+
proofSteps = [],
|
|
142
|
+
proofContext = new ProofContext(context, derived, variables, proofSteps);
|
|
142
143
|
|
|
143
144
|
return proofContext;
|
|
144
145
|
}
|
|
@@ -147,9 +148,9 @@ class ProofContext {
|
|
|
147
148
|
const context = proofContext, ///
|
|
148
149
|
derived = false,
|
|
149
150
|
variables = [],
|
|
150
|
-
|
|
151
|
+
proofSteps = [];
|
|
151
152
|
|
|
152
|
-
proofContext = new ProofContext(context, derived, variables,
|
|
153
|
+
proofContext = new ProofContext(context, derived, variables, proofSteps);
|
|
153
154
|
|
|
154
155
|
return proofContext;
|
|
155
156
|
}
|
package/src/equality.js
ADDED
package/src/metaSubstitution.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { matchNodes, bracketedChildNodeFromChildNodes } from "./utilities/node";
|
|
4
4
|
|
|
5
5
|
export default class MetaSubstitution {
|
|
6
6
|
constructor(metavariableName, nodes) {
|
|
@@ -19,34 +19,34 @@ export default class MetaSubstitution {
|
|
|
19
19
|
matchNodes(nodes) {
|
|
20
20
|
let matches;
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const nodesA = this.nodes, ///
|
|
23
|
+
nodesB = nodes,
|
|
24
|
+
metaSubstitutionNodesMatch = matchNodes(nodesA, nodesB);
|
|
24
25
|
|
|
25
|
-
matches =
|
|
26
|
+
matches = metaSubstitutionNodesMatch; ///
|
|
26
27
|
|
|
27
28
|
if (!matches) {
|
|
28
29
|
const childNodes = nodes, ///
|
|
29
|
-
|
|
30
|
-
const nonTerminalNode = bracketedMetastatementChildNode, ///
|
|
31
|
-
childNodes = nonTerminalNode.getChildNodes(),
|
|
32
|
-
nodes = childNodes, ///
|
|
33
|
-
metaAssertionNonTerminalNodeMatches = matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes),
|
|
34
|
-
bracketedMetastatementChildNodeMatches = metaAssertionNonTerminalNodeMatches; ///
|
|
30
|
+
bracketedChildNode = bracketedChildNodeFromChildNodes(childNodes);
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
if (bracketedChildNode !== null) {
|
|
33
|
+
const nonTerminalNode = bracketedChildNode, ///
|
|
34
|
+
childNodes = nonTerminalNode.getChildNodes(),
|
|
35
|
+
nodesB = childNodes, ///
|
|
36
|
+
nodesMatch = matchNodes(nodesA, nodesB);
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
matches = nodesMatch; ///
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return matches;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
static fromMetavariableNameAndNodes(metavariableName, nodes) {
|
|
46
|
-
const
|
|
46
|
+
const bracketedChildNode = bracketedChildNodeFromChildNodes(nodes);
|
|
47
47
|
|
|
48
|
-
if (
|
|
49
|
-
const nonTerminalNode =
|
|
48
|
+
if (bracketedChildNode !== null) {
|
|
49
|
+
const nonTerminalNode = bracketedChildNode, ///
|
|
50
50
|
childNodes = nonTerminalNode.getChildNodes();
|
|
51
51
|
|
|
52
52
|
nodes = childNodes; ///
|
|
@@ -57,74 +57,3 @@ export default class MetaSubstitution {
|
|
|
57
57
|
return metaSubstitution;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
function matchMetaSubstitutionNode(metaSubstitutionNode, node) {
|
|
62
|
-
let metaSubstitutionNodeMatches = false;
|
|
63
|
-
|
|
64
|
-
const nodeTerminalNode = node.isTerminalNode(),
|
|
65
|
-
ruleNodeTerminalNode = metaSubstitutionNode.isTerminalNode();
|
|
66
|
-
|
|
67
|
-
if (nodeTerminalNode === ruleNodeTerminalNode) {
|
|
68
|
-
if (nodeTerminalNode) {
|
|
69
|
-
const terminalNode = node, ///
|
|
70
|
-
metaSubstitutionTerminalNode = metaSubstitutionNode, ///
|
|
71
|
-
metaSubstitutionTerminalNodeMatches = matchMetaSubstitutionTerminalNode(metaSubstitutionTerminalNode, terminalNode);
|
|
72
|
-
|
|
73
|
-
metaSubstitutionNodeMatches = metaSubstitutionTerminalNodeMatches; ///
|
|
74
|
-
} else {
|
|
75
|
-
const nonTerminalNode = node, ///
|
|
76
|
-
metaSubstitutionNonTerminalNode = metaSubstitutionNode, ///
|
|
77
|
-
metaSubstitutionNonTerminalNodeMatches = matchMetaSubstitutionNonTerminalNode(metaSubstitutionNonTerminalNode, nonTerminalNode);
|
|
78
|
-
|
|
79
|
-
metaSubstitutionNodeMatches = metaSubstitutionNonTerminalNodeMatches; ///
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return metaSubstitutionNodeMatches;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes) {
|
|
87
|
-
let metaSubstitutionNodesMatches = false;
|
|
88
|
-
|
|
89
|
-
const nodesLength = nodes.length,
|
|
90
|
-
metaSubstitutionNodesLength = metaSubstitutionNodes.length;
|
|
91
|
-
|
|
92
|
-
if (nodesLength === metaSubstitutionNodesLength) {
|
|
93
|
-
metaSubstitutionNodesMatches = nodes.every((node, index) => {
|
|
94
|
-
const metaSubstitutionNode = metaSubstitutionNodes[index],
|
|
95
|
-
metaSubstitutionNodeMatches = matchMetaSubstitutionNode(metaSubstitutionNode, node);
|
|
96
|
-
|
|
97
|
-
if (metaSubstitutionNodeMatches) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return metaSubstitutionNodesMatches;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function matchMetaSubstitutionTerminalNode(metaSubstitutionTerminalNode, terminalNode) {
|
|
107
|
-
const matches = metaSubstitutionTerminalNode.match(terminalNode),
|
|
108
|
-
metaSubstitutionTerminalNodeMatches = matches; ///
|
|
109
|
-
|
|
110
|
-
return metaSubstitutionTerminalNodeMatches;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function matchMetaSubstitutionNonTerminalNode(metaSubstitutionNonTerminalNode, nonTerminalNode) {
|
|
114
|
-
let metaSubstitutionNonTerminalNodeMatches = false;
|
|
115
|
-
|
|
116
|
-
const ruleName = nonTerminalNode.getRuleName(),
|
|
117
|
-
metaSubstitutionRuleName = metaSubstitutionNonTerminalNode.getRuleName(); ///
|
|
118
|
-
|
|
119
|
-
if (ruleName === metaSubstitutionRuleName) {
|
|
120
|
-
const childNodes = nonTerminalNode.getChildNodes(),
|
|
121
|
-
metaSubstitutionChildNodes = metaSubstitutionNonTerminalNode.getChildNodes(),
|
|
122
|
-
nodes = childNodes, ///
|
|
123
|
-
metaSubstitutionNodes = metaSubstitutionChildNodes, ///
|
|
124
|
-
metaSubstitutionNodesMatches = matchMetaSubstitutionNodes(metaSubstitutionNodes, nodes);
|
|
125
|
-
|
|
126
|
-
metaSubstitutionNonTerminalNodeMatches = metaSubstitutionNodesMatches; ///
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return metaSubstitutionNonTerminalNodeMatches;
|
|
130
|
-
}
|
package/src/rule.js
CHANGED
|
@@ -51,10 +51,19 @@ export default class Rule {
|
|
|
51
51
|
|
|
52
52
|
metastatementNatches = conclusionMatches; ///
|
|
53
53
|
} else {
|
|
54
|
-
const
|
|
54
|
+
const metaproofSteps = metaproofContext.getMetaproofSteps();
|
|
55
55
|
|
|
56
|
-
metastatementNatches = someSubArray(
|
|
57
|
-
|
|
56
|
+
metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
|
|
57
|
+
let premisesMatchConclusion = false;
|
|
58
|
+
|
|
59
|
+
const metaSubstitutions = [],
|
|
60
|
+
premisesMatches = matchPremises(this.premises, metaproofSteps, metaSubstitutions);
|
|
61
|
+
|
|
62
|
+
if (premisesMatches) {
|
|
63
|
+
const conclusionMatches = matchConclusion(this.conclusion, metastatementNode, metaSubstitutions);
|
|
64
|
+
|
|
65
|
+
premisesMatchConclusion = conclusionMatches; ///
|
|
66
|
+
}
|
|
58
67
|
|
|
59
68
|
if (premisesMatchConclusion) {
|
|
60
69
|
return true;
|
|
@@ -136,10 +145,10 @@ export default class Rule {
|
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
|
|
139
|
-
function matchPremise(premise,
|
|
140
|
-
const
|
|
141
|
-
const metaSubproofNode =
|
|
142
|
-
metastatementNode =
|
|
148
|
+
function matchPremise(premise, metaproofSteps, metaSubstitutions) {
|
|
149
|
+
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
150
|
+
const metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
151
|
+
metastatementNode = metaproofStep.getMetastatementNode()
|
|
143
152
|
|
|
144
153
|
if (metaSubproofNode !== null) {
|
|
145
154
|
const metaSubProofMatches = premise.matchMetaSubproofNode(metaSubproofNode, metaSubstitutions);
|
|
@@ -156,17 +165,16 @@ function matchPremise(premise, metaAssertions, metaSubstitutions) {
|
|
|
156
165
|
return true;
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
|
-
|
|
160
168
|
}) || null;
|
|
161
169
|
|
|
162
|
-
const premiseMatches = (
|
|
170
|
+
const premiseMatches = (metaproofStep !== null);
|
|
163
171
|
|
|
164
172
|
return premiseMatches;
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
function matchPremises(premise,
|
|
175
|
+
function matchPremises(premise, metaproofSteps, metaSubstitutions) {
|
|
168
176
|
const premisesMatches = premise.every((premise) => {
|
|
169
|
-
const premiseMatches = matchPremise(premise,
|
|
177
|
+
const premiseMatches = matchPremise(premise, metaproofSteps, metaSubstitutions);
|
|
170
178
|
|
|
171
179
|
if (premiseMatches) {
|
|
172
180
|
return true;
|
|
@@ -182,18 +190,3 @@ function matchConclusion(conclusion, metastatementNode, metaSubstitutions) {
|
|
|
182
190
|
|
|
183
191
|
return conclusionMatches;
|
|
184
192
|
}
|
|
185
|
-
|
|
186
|
-
function matchPremisesAndConclusion(premises, conclusion, metaAssertions, metastatementNode) {
|
|
187
|
-
let premisesMatchConclusion = false;
|
|
188
|
-
|
|
189
|
-
const metaSubstitutions = [],
|
|
190
|
-
premisesMatches = matchPremises(premises, metaAssertions, metaSubstitutions);
|
|
191
|
-
|
|
192
|
-
if (premisesMatches) {
|
|
193
|
-
const conclusionMatches = matchConclusion(conclusion, metastatementNode, metaSubstitutions);
|
|
194
|
-
|
|
195
|
-
premisesMatchConclusion = conclusionMatches; ///
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return premisesMatchConclusion;
|
|
199
|
-
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { first, second } from "../utilities/array";
|
|
4
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
5
|
+
import { matchBracketedNonTerminalNode } from "../utilities/node";
|
|
6
|
+
|
|
7
|
+
const metastatementNodesQuery = nodesQuery("/metaSubproofAssertion/metastatement"),
|
|
8
|
+
metaSubproofAssertionNodeQuery = nodeQuery("/metastatement/metaSubproofAssertion"),
|
|
9
|
+
qualifiedOrUnqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/metaSubproof/qualifiedMetastatement|unqualifiedMetastatement/metastatement!");
|
|
10
|
+
|
|
11
|
+
export default class MetaproofStep {
|
|
12
|
+
constructor(metaSubproofNode, metastatementNode) {
|
|
13
|
+
this.metaSubproofNode = metaSubproofNode;
|
|
14
|
+
this.metastatementNode = metastatementNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getMetaSubproofNode() {
|
|
18
|
+
return this.metaSubproofNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getMetastatementNode() {
|
|
22
|
+
return this.metastatementNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
matchMetastatement(metastatementNode) {
|
|
26
|
+
let metastatementMatches;
|
|
27
|
+
|
|
28
|
+
const metaSubproofAssertionNode = metaSubproofAssertionNodeQuery(metastatementNode);
|
|
29
|
+
|
|
30
|
+
if (metaSubproofAssertionNode !== null) {
|
|
31
|
+
const metaSubproofAssertionMatches = this.matchMetaSubproofAssertion(metaSubproofAssertionNode);
|
|
32
|
+
|
|
33
|
+
metastatementMatches = metaSubproofAssertionMatches; ///
|
|
34
|
+
} else {
|
|
35
|
+
const metastatementsMatch = this.matchMetastatements(metastatementNode);
|
|
36
|
+
|
|
37
|
+
metastatementMatches = metastatementsMatch; //
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return metastatementMatches;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
matchMetastatements(metastatementNode) {
|
|
44
|
+
let metastatementsMatch = false;
|
|
45
|
+
|
|
46
|
+
if (this.metastatementNode !== null) {
|
|
47
|
+
const nonTerminalNodeA = metastatementNode, ///
|
|
48
|
+
nonTerminalNodeB = this.metastatementNode, ///
|
|
49
|
+
bracketedNodeMatches = matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB),
|
|
50
|
+
metastatementNodeMatches = bracketedNodeMatches; ///
|
|
51
|
+
|
|
52
|
+
return metastatementNodeMatches;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return metastatementsMatch;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
matchMetaSubproofAssertion(metaSubproofAssertionNode) {
|
|
59
|
+
let metaSubproofAssertionMatches = false;
|
|
60
|
+
|
|
61
|
+
if (this.metaSubproofNode !== null) {
|
|
62
|
+
const metaSubproofAssertionMetastatementNodes = metastatementNodesQuery(metaSubproofAssertionNode),
|
|
63
|
+
firstMetaSubproofAssertionMetastatementNode = first(metaSubproofAssertionMetastatementNodes),
|
|
64
|
+
qualifiedOrUnqualifiedMetastatementMetastatementNodes = qualifiedOrUnqualifiedMetastatementMetastatementNodesQuery(this.metaSubproofNode),
|
|
65
|
+
firstQualifiedOrUnqualifiedMetastatementMetastatementNode = first(qualifiedOrUnqualifiedMetastatementMetastatementNodes);
|
|
66
|
+
|
|
67
|
+
const nonTerminalNodeA = firstMetaSubproofAssertionMetastatementNode, ///
|
|
68
|
+
nonTerminalNodeB = firstQualifiedOrUnqualifiedMetastatementMetastatementNode, ///
|
|
69
|
+
bracketedNodeMatches = matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB);
|
|
70
|
+
|
|
71
|
+
if (bracketedNodeMatches) {
|
|
72
|
+
const secondMetaSubproofAssertionMetastatementNode = second(metaSubproofAssertionMetastatementNodes),
|
|
73
|
+
secondQualifiedOrUnqualifiedMetastatementMetastatementNode = second(qualifiedOrUnqualifiedMetastatementMetastatementNodes);
|
|
74
|
+
|
|
75
|
+
const nonTerminalNodeA = secondMetaSubproofAssertionMetastatementNode, ///
|
|
76
|
+
nonTerminalNodeB = secondQualifiedOrUnqualifiedMetastatementMetastatementNode, ///
|
|
77
|
+
bracketedNodeMatches = matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB);
|
|
78
|
+
|
|
79
|
+
metaSubproofAssertionMatches = bracketedNodeMatches; ///
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return metaSubproofAssertionMatches;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static fromMetaSubproofNode(metaSubproofNode) {
|
|
87
|
+
const metastatementNode = null,
|
|
88
|
+
metaProofStep = new MetaproofStep(metaSubproofNode, metastatementNode);
|
|
89
|
+
|
|
90
|
+
return metaProofStep;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static fromMetastatementNode(metastatementNode) {
|
|
94
|
+
const metaSubproofNode = null,
|
|
95
|
+
metaProofStep = new MetaproofStep(metaSubproofNode, metastatementNode);
|
|
96
|
+
|
|
97
|
+
return metaProofStep;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default class ProofStep {
|
|
4
|
+
constructor(subproofNode, statementNode) {
|
|
5
|
+
this.subproofNode = subproofNode;
|
|
6
|
+
this.statementNode = statementNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getSubproofNode() {
|
|
10
|
+
return this.subproofNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getStatementNode() {
|
|
14
|
+
return this.statementNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static fromSubproofNode(subproofNode) {
|
|
18
|
+
const statementNode = null,
|
|
19
|
+
metaProofStep = new ProofStep(subproofNode, statementNode);
|
|
20
|
+
|
|
21
|
+
return metaProofStep;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static fromStatementNode(statementNode) {
|
|
25
|
+
const subproofNode = null,
|
|
26
|
+
metaProofStep = new ProofStep(subproofNode, statementNode);
|
|
27
|
+
|
|
28
|
+
return metaProofStep;
|
|
29
|
+
}
|
|
30
|
+
}
|