occam-verify-cli 0.0.507 → 0.0.508
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/axiomLemmaTheorem.js +2 -2
- package/lib/conclusion.js +6 -6
- package/lib/consequence.js +4 -4
- package/lib/matcher/metastatementForMetavariable/conclusion.js +113 -0
- package/lib/matcher/metastatementForMetavariable/premise.js +113 -0
- package/lib/matcher/metastatementForMetavariable.js +201 -0
- package/lib/matcher/statementForMetavariable/conclusion.js +113 -0
- package/lib/matcher/statementForMetavariable/premise.js +113 -0
- package/lib/matcher/statementForMetavariable.js +201 -0
- package/lib/matcher/statementForVariable/consequence.js +113 -0
- package/lib/matcher/statementForVariable/supposition.js +113 -0
- package/lib/matcher/statementForVariable.js +201 -0
- package/lib/matcher.js +124 -10
- package/lib/premise.js +19 -19
- package/lib/rule.js +11 -11
- package/lib/substitution/metastatementForMetavariable.js +86 -0
- package/lib/substitution/statementForMetavariable.js +86 -0
- package/lib/substitution/statementForVariable.js +86 -0
- package/lib/supposition.js +9 -9
- package/package.json +1 -1
- package/src/axiomLemmaTheorem.js +1 -1
- package/src/conclusion.js +9 -9
- package/src/consequence.js +5 -5
- package/src/matcher/metastatementForMetavariable/conclusion.js +9 -0
- package/src/matcher/metastatementForMetavariable/premise.js +9 -0
- package/src/matcher/metastatementForMetavariable.js +99 -0
- package/src/matcher/statementForMetavariable/conclusion.js +9 -0
- package/src/matcher/statementForMetavariable/premise.js +9 -0
- package/src/matcher/statementForMetavariable.js +99 -0
- package/src/matcher/statementForVariable/consequence.js +9 -0
- package/src/matcher/statementForVariable/supposition.js +9 -0
- package/src/matcher/statementForVariable.js +99 -0
- package/src/matcher.js +70 -3
- package/src/premise.js +42 -42
- package/src/rule.js +12 -12
- package/src/{metaSubstitution.js → substitution/metastatementForMetavariable.js} +7 -7
- package/src/{substitution.js → substitution/statementForMetavariable.js} +7 -7
- package/src/substitution/statementForVariable.js +64 -0
- package/src/supposition.js +20 -20
- package/lib/matcher/conclusion.js +0 -194
- package/lib/matcher/consequence.js +0 -194
- package/lib/matcher/premise.js +0 -199
- package/lib/matcher/supposition.js +0 -199
- package/lib/metaMatcher/conclusion.js +0 -194
- package/lib/metaMatcher/premise.js +0 -199
- package/lib/metaMatcher.js +0 -36
- package/lib/metaSubstitution.js +0 -86
- package/lib/mixins/matcher.js +0 -109
- package/lib/substitution.js +0 -86
- package/src/matcher/conclusion.js +0 -86
- package/src/matcher/consequence.js +0 -89
- package/src/matcher/premise.js +0 -94
- package/src/matcher/supposition.js +0 -97
- package/src/metaMatcher/conclusion.js +0 -86
- package/src/metaMatcher/premise.js +0 -94
- package/src/metaMatcher.js +0 -9
- package/src/mixins/matcher.js +0 -81
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetastatementForMetavariableMatcher from "../../matcher/metastatementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class PremiseMetastatementForMetavariableMatcher extends MetastatementForMetavariableMatcher {
|
|
6
|
+
static createSubstitutions = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const premiseMetastatementForMetavariableMatcher = new PremiseMetastatementForMetavariableMatcher();
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Matcher from "../matcher";
|
|
4
|
+
import MetastatementForMetavariableSubstitution from "../substitution/metastatementForMetavariable";
|
|
5
|
+
|
|
6
|
+
import { first } from "../utilities/array";
|
|
7
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
8
|
+
import { METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
9
|
+
|
|
10
|
+
export default class MetastatementForMetavariableMatcher extends Matcher {
|
|
11
|
+
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
12
|
+
let nonTerminalNodeMatches = false;
|
|
13
|
+
|
|
14
|
+
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
15
|
+
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
16
|
+
nonTerminalNodeARuleNameMetastatementRuleName = (nonTerminalNodeARuleName === METASTATEMENT_RULE_NAME),
|
|
17
|
+
nonTerminalNodeBRuleNameMetastatementRuleName = (nonTerminalNodeBRuleName === METASTATEMENT_RULE_NAME);
|
|
18
|
+
|
|
19
|
+
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
|
|
20
|
+
const metastatementNodeA = nonTerminalNodeA, ///
|
|
21
|
+
metastatementNodeB = nonTerminalNodeB, ///
|
|
22
|
+
metastatementNodeMatches = this.matchMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions);
|
|
23
|
+
|
|
24
|
+
if (metastatementNodeMatches) {
|
|
25
|
+
nonTerminalNodeMatches = true; ///
|
|
26
|
+
} else {
|
|
27
|
+
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
28
|
+
}
|
|
29
|
+
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
30
|
+
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return nonTerminalNodeMatches;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
matchMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions) {
|
|
37
|
+
let metastatementNodeMatches = false;
|
|
38
|
+
|
|
39
|
+
const nonTerminalNodeA = metastatementNodeA, ///
|
|
40
|
+
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
41
|
+
nonTerminalNodeAChildNodesLength = nonTerminalNodeAChildNodes.length;
|
|
42
|
+
|
|
43
|
+
if (nonTerminalNodeAChildNodesLength === 1) {
|
|
44
|
+
const firstNonTerminalNodeAChildNode = first(nonTerminalNodeAChildNodes),
|
|
45
|
+
cChildNodeA = firstNonTerminalNodeAChildNode, ///
|
|
46
|
+
cChildNodeANonTerminalNode = cChildNodeA.isNonTerminalNode();
|
|
47
|
+
|
|
48
|
+
if (cChildNodeANonTerminalNode) {
|
|
49
|
+
const nonTerminalNodeA = cChildNodeA, ///
|
|
50
|
+
nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
51
|
+
nonTerminalNodeARuleNameMetavariableRuleName = (nonTerminalNodeARuleName === METAVARIABLE_RULE_NAME);
|
|
52
|
+
|
|
53
|
+
if (nonTerminalNodeARuleNameMetavariableRuleName) {
|
|
54
|
+
const metavariableNodeA = nonTerminalNodeA, ///
|
|
55
|
+
metaVariableNodeMatches = this.matchMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions);
|
|
56
|
+
|
|
57
|
+
metastatementNodeMatches = metaVariableNodeMatches; ///
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return metastatementNodeMatches;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
matchMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions) {
|
|
66
|
+
let metavariableNodeMatches;
|
|
67
|
+
|
|
68
|
+
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
69
|
+
substitution = substitutions.find((substitution) => {
|
|
70
|
+
const metavariableName = substitution.getMetavariableName();
|
|
71
|
+
|
|
72
|
+
if (metavariableName === metavariableNameA) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}) || null;
|
|
76
|
+
|
|
77
|
+
if (substitution !== null) {
|
|
78
|
+
const metastatementNode = metastatementNodeB, ///
|
|
79
|
+
substitutionNodesMatch = substitution.matchMetastatementNode(metastatementNode);
|
|
80
|
+
|
|
81
|
+
metavariableNodeMatches = substitutionNodesMatch; ///
|
|
82
|
+
} else {
|
|
83
|
+
const { createSubstitutions } = this.constructor;
|
|
84
|
+
|
|
85
|
+
if (createSubstitutions) {
|
|
86
|
+
const metavariableName = metavariableNameA, ///
|
|
87
|
+
metastatementNode = metastatementNodeB, ///
|
|
88
|
+
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNameAndMetastatementNode(metavariableName, metastatementNode),
|
|
89
|
+
substitution = metastatementForMetavariableSubstitution; ///
|
|
90
|
+
|
|
91
|
+
substitutions.push(substitution);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
metavariableNodeMatches = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return metavariableNodeMatches;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForMetavariableMatcher from "../../matcher/statementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class ConclusionStatementForMetavariableMatcher extends StatementForMetavariableMatcher {
|
|
6
|
+
static createSubstitutions = false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const conclusionStatementForMetavariableMatcher = new ConclusionStatementForMetavariableMatcher();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForMetavariableMatcher from "../../matcher/statementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class PremiseStatementForMetavariableMatcher extends StatementForMetavariableMatcher {
|
|
6
|
+
static createSubstitutions = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const premiseStatementForMetavariableMatcher = new PremiseStatementForMetavariableMatcher();
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Matcher from "../matcher";
|
|
4
|
+
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
5
|
+
|
|
6
|
+
import { first } from "../utilities/array";
|
|
7
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
8
|
+
import { METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
9
|
+
|
|
10
|
+
export default class StatementForMetavariableMatcher extends Matcher {
|
|
11
|
+
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
12
|
+
let nonTerminalNodeMatches = false;
|
|
13
|
+
|
|
14
|
+
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
15
|
+
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
16
|
+
nonTerminalNodeARuleNameMetastatementRuleName = (nonTerminalNodeARuleName === METASTATEMENT_RULE_NAME),
|
|
17
|
+
nonTerminalNodeBRuleNameStatementRuleName = (nonTerminalNodeBRuleName === STATEMENT_RULE_NAME);
|
|
18
|
+
|
|
19
|
+
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameStatementRuleName) {
|
|
20
|
+
const metastatementNodeA = nonTerminalNodeA, ///
|
|
21
|
+
statementNodeB = nonTerminalNodeB, ///
|
|
22
|
+
statementNodeMatches = this.matchStatementNode(metastatementNodeA, statementNodeB, substitutions);
|
|
23
|
+
|
|
24
|
+
if (statementNodeMatches) {
|
|
25
|
+
nonTerminalNodeMatches = true; ///
|
|
26
|
+
} else {
|
|
27
|
+
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
28
|
+
}
|
|
29
|
+
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
30
|
+
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return nonTerminalNodeMatches;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
matchStatementNode(metastatementNodeA, statementNodeB, substitutions) {
|
|
37
|
+
let statementNodeMatches = false;
|
|
38
|
+
|
|
39
|
+
const nonTerminalNodeA = metastatementNodeA, ///
|
|
40
|
+
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
41
|
+
nonTerminalNodeAChildNodesLength = nonTerminalNodeAChildNodes.length;
|
|
42
|
+
|
|
43
|
+
if (nonTerminalNodeAChildNodesLength === 1) {
|
|
44
|
+
const firstNonTerminalNodeAChildNode = first(nonTerminalNodeAChildNodes),
|
|
45
|
+
cChildNodeA = firstNonTerminalNodeAChildNode, ///
|
|
46
|
+
cChildNodeANonTerminalNode = cChildNodeA.isNonTerminalNode();
|
|
47
|
+
|
|
48
|
+
if (cChildNodeANonTerminalNode) {
|
|
49
|
+
const nonTerminalNodeA = cChildNodeA, ///
|
|
50
|
+
nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
51
|
+
nonTerminalNodeARuleNameMetavariableRuleName = (nonTerminalNodeARuleName === METAVARIABLE_RULE_NAME);
|
|
52
|
+
|
|
53
|
+
if (nonTerminalNodeARuleNameMetavariableRuleName) {
|
|
54
|
+
const metavariableNodeA = nonTerminalNodeA, ///
|
|
55
|
+
metaVariableNodeMatches = this.matchMetavariableNode(metavariableNodeA, statementNodeB, substitutions);
|
|
56
|
+
|
|
57
|
+
statementNodeMatches = metaVariableNodeMatches; ///
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return statementNodeMatches;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
matchMetavariableNode(metavariableNodeA, statementNodeB, substitutions) {
|
|
66
|
+
let metavariableNodeMatches;
|
|
67
|
+
|
|
68
|
+
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
69
|
+
substitution = substitutions.find((substitution) => {
|
|
70
|
+
const metavariableName = substitution.getMetavariableName();
|
|
71
|
+
|
|
72
|
+
if (metavariableName === metavariableNameA) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}) || null;
|
|
76
|
+
|
|
77
|
+
if (substitution !== null) {
|
|
78
|
+
const statementNode = statementNodeB, ///
|
|
79
|
+
substitutionNodesMatch = substitution.matchStatementNode(statementNode);
|
|
80
|
+
|
|
81
|
+
metavariableNodeMatches = substitutionNodesMatch; ///
|
|
82
|
+
} else {
|
|
83
|
+
const { createSubstitutions } = this.constructor;
|
|
84
|
+
|
|
85
|
+
if (createSubstitutions) {
|
|
86
|
+
const metavariableName = metavariableNameA, ///
|
|
87
|
+
statementNode = statementNodeB, ///
|
|
88
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNameAndStatementNode(metavariableName, statementNode),
|
|
89
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
90
|
+
|
|
91
|
+
substitutions.push(substitution);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
metavariableNodeMatches = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return metavariableNodeMatches;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForVariableMatcher from "../../matcher/statementForVariable";
|
|
4
|
+
|
|
5
|
+
class ConsequenceStatementForVariableMatcher extends StatementForVariableMatcher {
|
|
6
|
+
static createSubstitutions = false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const consequenceStatementForVariableMatcher = new ConsequenceStatementForVariableMatcher();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForVariableMatcher from "../../matcher/statementForVariable";
|
|
4
|
+
|
|
5
|
+
class SuppositionStatementForVariableMatcher extends StatementForVariableMatcher {
|
|
6
|
+
static createSubstitutions = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const suppositionStatementForVariableMatcher = new SuppositionStatementForVariableMatcher();
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Matcher from "../matcher";
|
|
4
|
+
import StatementForVariableSubstitution from "../substitution/statementForVariable";
|
|
5
|
+
|
|
6
|
+
import { first } from "../utilities/array";
|
|
7
|
+
import { variableNameFromVariableNode } from "../utilities/query";
|
|
8
|
+
import { VARIABLE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
9
|
+
|
|
10
|
+
export default class StatementForVariableMatcher extends Matcher {
|
|
11
|
+
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
12
|
+
let nonTerminalNodeMatches = false;
|
|
13
|
+
|
|
14
|
+
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
15
|
+
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
16
|
+
nonTerminalNodeARuleNameMetastatementRuleName = (nonTerminalNodeARuleName === STATEMENT_RULE_NAME),
|
|
17
|
+
nonTerminalNodeBRuleNameMetastatementRuleName = (nonTerminalNodeBRuleName === STATEMENT_RULE_NAME);
|
|
18
|
+
|
|
19
|
+
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
|
|
20
|
+
const statementNodeA = nonTerminalNodeA, ///
|
|
21
|
+
statementNodeB = nonTerminalNodeB, ///
|
|
22
|
+
statementNodeMatches = this.matchStatementNode(statementNodeA, statementNodeB, substitutions);
|
|
23
|
+
|
|
24
|
+
if (statementNodeMatches) {
|
|
25
|
+
nonTerminalNodeMatches = true; ///
|
|
26
|
+
} else {
|
|
27
|
+
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
28
|
+
}
|
|
29
|
+
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
30
|
+
nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return nonTerminalNodeMatches;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
matchStatementNode(statementNodeA, statementNodeB, substitutions) {
|
|
37
|
+
let statementNodeMatches = false;
|
|
38
|
+
|
|
39
|
+
const nonTerminalNodeA = statementNodeA, ///
|
|
40
|
+
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
41
|
+
nonTerminalNodeAChildNodesLength = nonTerminalNodeAChildNodes.length;
|
|
42
|
+
|
|
43
|
+
if (nonTerminalNodeAChildNodesLength === 1) {
|
|
44
|
+
const firstNonTerminalNodeAChildNode = first(nonTerminalNodeAChildNodes),
|
|
45
|
+
childNodeA = firstNonTerminalNodeAChildNode, ///
|
|
46
|
+
childNodeANonTerminalNode = childNodeA.isNonTerminalNode();
|
|
47
|
+
|
|
48
|
+
if (childNodeANonTerminalNode) {
|
|
49
|
+
const nonTerminalNodeA = childNodeA, ///
|
|
50
|
+
nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
51
|
+
nonTerminalNodeARuleNameVariableRuleName = (nonTerminalNodeARuleName === VARIABLE_RULE_NAME);
|
|
52
|
+
|
|
53
|
+
if (nonTerminalNodeARuleNameVariableRuleName) {
|
|
54
|
+
const variableNodeA = nonTerminalNodeA, ///
|
|
55
|
+
variableMatches = this.matchVariableNode(variableNodeA, statementNodeB, substitutions);
|
|
56
|
+
|
|
57
|
+
statementNodeMatches = variableMatches; ///
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return statementNodeMatches;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
matchVariableNode(variableNodeB, statementNodeB, substitutions) {
|
|
66
|
+
let variableMatches;
|
|
67
|
+
|
|
68
|
+
const variableNameA = variableNameFromVariableNode(variableNodeB),
|
|
69
|
+
substitution = substitutions.find((substitution) => {
|
|
70
|
+
const variableName = substitution.getVariableName();
|
|
71
|
+
|
|
72
|
+
if (variableName === variableNameA) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}) || null;
|
|
76
|
+
|
|
77
|
+
if (substitution !== null) {
|
|
78
|
+
const statementNode = statementNodeB, ///
|
|
79
|
+
substitutionNodesMatch = substitution.matchStatementNode(statementNode);
|
|
80
|
+
|
|
81
|
+
variableMatches = substitutionNodesMatch; ///
|
|
82
|
+
} else {
|
|
83
|
+
const { createSubstitutions } = this.constructor;
|
|
84
|
+
|
|
85
|
+
if (createSubstitutions) {
|
|
86
|
+
const variableName = variableNameA, ///
|
|
87
|
+
statementNode = statementNodeB, ///
|
|
88
|
+
statementForVariableSubstitution = StatementForVariableSubstitution.fromVariableNameAndStatementNode(variableName, statementNode),
|
|
89
|
+
substitution = statementForVariableSubstitution; ///
|
|
90
|
+
|
|
91
|
+
substitutions.push(substitution);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
variableMatches = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return variableMatches;
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/matcher.js
CHANGED
|
@@ -1,9 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default class Matcher {
|
|
4
|
+
matchNode(nodeA, nodeB, ...remainingArguments) {
|
|
5
|
+
let nodeMatches = false;
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const nodeATerminalNode = nodeA.isTerminalNode(),
|
|
8
|
+
nodeBTerminalNode = nodeB.isTerminalNode();
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
if (nodeATerminalNode === nodeBTerminalNode) {
|
|
11
|
+
if (nodeATerminalNode) {
|
|
12
|
+
const terminalNodeA = nodeA, ///
|
|
13
|
+
terminalNodeB = nodeB, ///
|
|
14
|
+
terminalNodeMatches = this.matchTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments);
|
|
15
|
+
|
|
16
|
+
nodeMatches = terminalNodeMatches; ///
|
|
17
|
+
} else {
|
|
18
|
+
const nonTerminalNodeA = nodeA, ///
|
|
19
|
+
nonTerminalNodeB = nodeB, ///
|
|
20
|
+
nonTerminalNodeMatches = this.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments);
|
|
21
|
+
|
|
22
|
+
nodeMatches = nonTerminalNodeMatches; ///
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return nodeMatches;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
matchNodes(nodesA, nodesB, ...remainingArguments) {
|
|
30
|
+
let nodesMatch = false;
|
|
31
|
+
|
|
32
|
+
const nodesALength = nodesA.length,
|
|
33
|
+
nodesBLength = nodesB.length;
|
|
34
|
+
|
|
35
|
+
if (nodesALength === nodesBLength) {
|
|
36
|
+
nodesMatch = nodesA.every((nodeA, index) => {
|
|
37
|
+
const nodeB = nodesB[index],
|
|
38
|
+
nodeMatches = this.matchNode(nodeA, nodeB, ...remainingArguments);
|
|
39
|
+
|
|
40
|
+
if (nodeMatches) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return nodesMatch;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
matchTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments) {
|
|
50
|
+
const matches = terminalNodeA.match(terminalNodeB),
|
|
51
|
+
terminalNodeMatches = matches; ///
|
|
52
|
+
|
|
53
|
+
return terminalNodeMatches;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments) {
|
|
57
|
+
let nonTerminalNodeMatches = false;
|
|
58
|
+
|
|
59
|
+
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(), ///
|
|
60
|
+
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(); ///
|
|
61
|
+
|
|
62
|
+
if (nonTerminalNodeARuleName === nonTerminalNodeBRuleName) {
|
|
63
|
+
const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
64
|
+
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
65
|
+
nodesA = nonTerminalNodeAChildNodes, ///
|
|
66
|
+
nodesB = nonTerminalNodeBChildNodes, ///
|
|
67
|
+
nodesMatch = this.matchNodes(nodesA, nodesB, ...remainingArguments);
|
|
68
|
+
|
|
69
|
+
nonTerminalNodeMatches = nodesMatch; ///
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return nonTerminalNodeMatches;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
8
75
|
|
|
9
76
|
export const matcher = new Matcher();
|
package/src/premise.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { nodeAsString } from "./utilities/string";
|
|
4
|
-
import { premiseMatcher } from "./matcher/premise";
|
|
5
|
-
import { premiseMetaMatcher } from "./metaMatcher/premise";
|
|
6
4
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
5
|
+
import { premiseStatementForMetavariableMatcher } from "./matcher/statementForMetavariable/premise";
|
|
7
6
|
import { metastatementNodeFromMetastatementString } from "./utilities/string";
|
|
7
|
+
import { premiseMetastatementForMetavariableMatcher } from "./matcher/metastatementForMetavariable/premise";
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const ruleSubproofAssertionNodeQuery = nodeQuery("/metastatement/ruleSubproofAssertion!"),
|
|
10
|
+
ruleSubproofPremiseMetastatementQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
11
|
+
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement!/statement!"),
|
|
12
|
+
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!"),
|
|
13
|
+
ruleSubproofAssertionMetastatementNodesQuery = nodesQuery("/ruleSubproofAssertion/metastatement"),
|
|
14
|
+
ruleSubproofSubDerivationLastMetastatementQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
|
|
15
15
|
|
|
16
16
|
export default class Premise {
|
|
17
17
|
constructor(metastatementNode) {
|
|
@@ -28,22 +28,22 @@ export default class Premise {
|
|
|
28
28
|
const subproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
29
29
|
|
|
30
30
|
if (subproofAssertionNode !== null) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
subDerivationStatementNode
|
|
31
|
+
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
32
|
+
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
33
|
+
subproofStatementNodes = [
|
|
34
|
+
...subproofSuppositionStatementNodes,
|
|
35
|
+
subproofSubDerivationLastStatementNode
|
|
37
36
|
],
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
ruleSubproofAssertionMetaSubproofStatementNodes = ruleSubproofAssertionMetaSubproofStatementNodesQuery(subproofAssertionNode),
|
|
38
|
+
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
39
|
+
ruleSubproofAssertionMetaSubproofStatementNodesLength = ruleSubproofAssertionMetaSubproofStatementNodes.length;
|
|
40
40
|
|
|
41
|
-
if (
|
|
42
|
-
subproofNodeMatches =
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
nonTerminalNodeMatches =
|
|
41
|
+
if (subproofStatementNodesLength === ruleSubproofAssertionMetaSubproofStatementNodesLength) {
|
|
42
|
+
subproofNodeMatches = ruleSubproofAssertionMetaSubproofStatementNodes.every((ruleSubproofAssertionMetastatementNode, index) => {
|
|
43
|
+
const subproofStatementNode = subproofStatementNodes[index],
|
|
44
|
+
nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
45
|
+
nonTerminalNodeB = subproofStatementNode, ///
|
|
46
|
+
nonTerminalNodeMatches = premiseStatementForMetavariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
47
47
|
|
|
48
48
|
if (nonTerminalNodeMatches) {
|
|
49
49
|
return true;
|
|
@@ -56,36 +56,36 @@ export default class Premise {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
matchStatementNode(statementNode, substitutions) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
nonTerminalNodeMatches =
|
|
59
|
+
const nonTerminalNodeA = this.metastatementNode, ///
|
|
60
|
+
nonTerminalNodeB = statementNode, ///
|
|
61
|
+
nonTerminalNodeMatches = premiseStatementForMetavariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
|
|
62
62
|
statementNodeMatches = nonTerminalNodeMatches; ///
|
|
63
63
|
|
|
64
64
|
return statementNodeMatches;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
matchRuleSubproofNode(ruleSubproofNode,
|
|
67
|
+
matchRuleSubproofNode(ruleSubproofNode, substitutions) {
|
|
68
68
|
let ruleSubproofNodeMatches = false;
|
|
69
69
|
|
|
70
70
|
const ruleSubproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
71
71
|
|
|
72
72
|
if (ruleSubproofAssertionNode !== null) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
ruleSubDerivationMetastatementNode
|
|
73
|
+
const ruleSubproofPremiseMetastatement = ruleSubproofPremiseMetastatementQuery(ruleSubproofNode),
|
|
74
|
+
ruleSubproofSubDerivationLastMetastatement = ruleSubproofSubDerivationLastMetastatementQuery(ruleSubproofNode),
|
|
75
|
+
ruleSubproofMetastatementNodes = [
|
|
76
|
+
...ruleSubproofPremiseMetastatement,
|
|
77
|
+
ruleSubproofSubDerivationLastMetastatement
|
|
79
78
|
],
|
|
80
|
-
|
|
79
|
+
ruleSubproofMetastatementNodesLength = ruleSubproofMetastatementNodes.length,
|
|
80
|
+
ruleSubproofAssertionMetastatementNodes = ruleSubproofAssertionMetastatementNodesQuery(ruleSubproofAssertionNode),
|
|
81
81
|
ruleSubproofAssertionMetastatementNodesLength = ruleSubproofAssertionMetastatementNodes.length;
|
|
82
82
|
|
|
83
|
-
if (
|
|
83
|
+
if (ruleSubproofMetastatementNodesLength === ruleSubproofAssertionMetastatementNodesLength) {
|
|
84
84
|
ruleSubproofNodeMatches = ruleSubproofAssertionMetastatementNodes.every((ruleSubproofAssertionMetastatementNode, index) => {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
nonTerminalNodeMatches =
|
|
85
|
+
const ruleSubproofMetastatementNode = ruleSubproofMetastatementNodes[index],
|
|
86
|
+
nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
87
|
+
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
88
|
+
nonTerminalNodeMatches = premiseMetastatementForMetavariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
89
89
|
|
|
90
90
|
if (nonTerminalNodeMatches) {
|
|
91
91
|
return true;
|
|
@@ -97,10 +97,10 @@ export default class Premise {
|
|
|
97
97
|
return ruleSubproofNodeMatches;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
matchMetastatementNode(metastatementNode,
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
nonTerminalNodeMatches =
|
|
100
|
+
matchMetastatementNode(metastatementNode, substitutions) {
|
|
101
|
+
const nonTerminalNodeA = this.metastatementNode, ///
|
|
102
|
+
nonTerminalNodeB = metastatementNode, ///
|
|
103
|
+
nonTerminalNodeMatches = premiseMetastatementForMetavariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
|
|
104
104
|
metastatementNodeMatches = nonTerminalNodeMatches; ///
|
|
105
105
|
|
|
106
106
|
return metastatementNodeMatches;
|
package/src/rule.js
CHANGED
|
@@ -80,8 +80,8 @@ export default class Rule {
|
|
|
80
80
|
const premisesLength = this.premises.length;
|
|
81
81
|
|
|
82
82
|
if (premisesLength === 0) {
|
|
83
|
-
const
|
|
84
|
-
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode,
|
|
83
|
+
const substitutions = [],
|
|
84
|
+
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions);
|
|
85
85
|
|
|
86
86
|
metastatementNatches = conclusionMatches; ///
|
|
87
87
|
} else {
|
|
@@ -90,11 +90,11 @@ export default class Rule {
|
|
|
90
90
|
metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
|
|
91
91
|
let premisesMatchConclusion = false;
|
|
92
92
|
|
|
93
|
-
const
|
|
94
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps,
|
|
93
|
+
const substitutions = [],
|
|
94
|
+
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions);
|
|
95
95
|
|
|
96
96
|
if (premisesMatch) {
|
|
97
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode,
|
|
97
|
+
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions);
|
|
98
98
|
|
|
99
99
|
premisesMatchConclusion = conclusionMatches; ///
|
|
100
100
|
}
|
|
@@ -225,13 +225,13 @@ function matchConclusion(conclusion, statementNode, substitutions) {
|
|
|
225
225
|
return conclusionMatches;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
function metaMatchPremise(premise, metaproofSteps,
|
|
228
|
+
function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
229
229
|
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
230
230
|
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
231
231
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
232
232
|
|
|
233
233
|
if (ruleSubproofNode !== null) {
|
|
234
|
-
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode,
|
|
234
|
+
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions);
|
|
235
235
|
|
|
236
236
|
if (!ruleSubProofNodeMatches) { ///
|
|
237
237
|
return true;
|
|
@@ -239,7 +239,7 @@ function metaMatchPremise(premise, metaproofSteps, metaSubstitutions) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
if (metastatementNode !== null) {
|
|
242
|
-
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode,
|
|
242
|
+
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions);
|
|
243
243
|
|
|
244
244
|
if (!metastatementNodeMatches) { ///
|
|
245
245
|
return true;
|
|
@@ -252,9 +252,9 @@ function metaMatchPremise(premise, metaproofSteps, metaSubstitutions) {
|
|
|
252
252
|
return premiseMatches;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
function metaMatchPremises(premise, metaproofSteps,
|
|
255
|
+
function metaMatchPremises(premise, metaproofSteps, substitutions) {
|
|
256
256
|
const premisesMatch = premise.every((premise) => {
|
|
257
|
-
const premiseMatches = metaMatchPremise(premise, metaproofSteps,
|
|
257
|
+
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions);
|
|
258
258
|
|
|
259
259
|
if (premiseMatches) {
|
|
260
260
|
return true;
|
|
@@ -264,8 +264,8 @@ function metaMatchPremises(premise, metaproofSteps, metaSubstitutions) {
|
|
|
264
264
|
return premisesMatch;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
function metaMatchConclusion(conclusion, metastatementNode,
|
|
268
|
-
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode,
|
|
267
|
+
function metaMatchConclusion(conclusion, metastatementNode, substitutions) {
|
|
268
|
+
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions),
|
|
269
269
|
conclusionMatches = metastatementNodeMatches; ///
|
|
270
270
|
|
|
271
271
|
return conclusionMatches;
|