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
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Matcher from "../matcher";
|
|
4
|
-
|
|
5
|
-
import { first } from "../utilities/array";
|
|
6
|
-
import { variableNameFromVariableNode } from "../utilities/query";
|
|
7
|
-
import { VARIABLE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
8
|
-
|
|
9
|
-
class ConsequenceMatcher extends Matcher {
|
|
10
|
-
matchNonTerminalNode(consequenceNonTerminalNode, nonTerminalNode, metaSubstitutions) {
|
|
11
|
-
let nonTerminalNodeMatches = false;
|
|
12
|
-
|
|
13
|
-
const ruleName = nonTerminalNode.getRuleName(),
|
|
14
|
-
consequenceRuleName = consequenceNonTerminalNode.getRuleName(); ///
|
|
15
|
-
|
|
16
|
-
if (ruleName === consequenceRuleName) {
|
|
17
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(consequenceNonTerminalNode, nonTerminalNode, metaSubstitutions);
|
|
18
|
-
|
|
19
|
-
if (!nonTerminalNodeMatches) {
|
|
20
|
-
const ruleNameStatementRuleName = (ruleName === STATEMENT_RULE_NAME);
|
|
21
|
-
|
|
22
|
-
if (ruleNameStatementRuleName) {
|
|
23
|
-
const statementNode = nonTerminalNode, ///
|
|
24
|
-
consequenceStatementNode = consequenceNonTerminalNode, ///
|
|
25
|
-
statementNodeMatches = this.matchStatementNode(consequenceStatementNode, statementNode, metaSubstitutions);
|
|
26
|
-
|
|
27
|
-
nonTerminalNodeMatches = statementNodeMatches; ///
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return nonTerminalNodeMatches;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
matchStatementNode(consequenceStatementNode, statementNode, metaSubstitutions) {
|
|
36
|
-
let statementNodeMatches = false;
|
|
37
|
-
|
|
38
|
-
const consequenceNonTerminalNode = consequenceStatementNode, ///
|
|
39
|
-
consequenceChildNodes = consequenceNonTerminalNode.getChildNodes(),
|
|
40
|
-
consequenceChildNodesLength = consequenceChildNodes.length;
|
|
41
|
-
|
|
42
|
-
if (consequenceChildNodesLength === 1) {
|
|
43
|
-
const firstConsequenceChildNode = first(consequenceChildNodes),
|
|
44
|
-
consequenceChildNode = firstConsequenceChildNode, ///
|
|
45
|
-
consequenceChildNodeNonTerminalNode = consequenceChildNode.isNonTerminalNode();
|
|
46
|
-
|
|
47
|
-
if (consequenceChildNodeNonTerminalNode) {
|
|
48
|
-
const consequenceNonTerminalChildNode = consequenceChildNode, ///
|
|
49
|
-
consequenceNonTerminalChildNodeRuleName = consequenceNonTerminalChildNode.getRuleName(),
|
|
50
|
-
consequenceNonTerminalChildNodeRuleNameVariableRuleName = (consequenceNonTerminalChildNodeRuleName === VARIABLE_RULE_NAME);
|
|
51
|
-
|
|
52
|
-
if (consequenceNonTerminalChildNodeRuleNameVariableRuleName) {
|
|
53
|
-
const consequenceVariableNode = consequenceNonTerminalChildNode, ///
|
|
54
|
-
nonTerminalNode = statementNode, ///
|
|
55
|
-
childNodes = nonTerminalNode.getChildNodes(),
|
|
56
|
-
nodes = childNodes, ///
|
|
57
|
-
variableMatches = this.matchVariable(consequenceVariableNode, nodes, metaSubstitutions);
|
|
58
|
-
|
|
59
|
-
statementNodeMatches = variableMatches; ///
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return statementNodeMatches;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
matchVariable(consequenceVariableNode, nodes, metaSubstitutions) {
|
|
68
|
-
let variableMatches = true;
|
|
69
|
-
|
|
70
|
-
const consequenceVariableName = variableNameFromVariableNode(consequenceVariableNode),
|
|
71
|
-
metaSubstitution = metaSubstitutions.find((metaSubstitution) => {
|
|
72
|
-
const variableName = metaSubstitution.getVariableName();
|
|
73
|
-
|
|
74
|
-
if (variableName === consequenceVariableName) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}) || null;
|
|
78
|
-
|
|
79
|
-
if (metaSubstitution !== null) {
|
|
80
|
-
const metaSubstitutionNodesMatch = metaSubstitution.matchNodes(nodes);
|
|
81
|
-
|
|
82
|
-
variableMatches = metaSubstitutionNodesMatch; ///
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return variableMatches;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const consequenceMatcher = new ConsequenceMatcher();
|
package/src/matcher/premise.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Matcher from "../matcher";
|
|
4
|
-
import Substitution from "../substitution";
|
|
5
|
-
|
|
6
|
-
import { first } from "../utilities/array";
|
|
7
|
-
import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
8
|
-
import { STATEMENT_RULE_NAME, METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME} from "../ruleNames";
|
|
9
|
-
|
|
10
|
-
class PremiseMatcher extends Matcher {
|
|
11
|
-
matchNonTerminalNode(premiseNonTerminalNode, nonTerminalNode, substitutions) {
|
|
12
|
-
let nonTerminalNodeMatches = false;
|
|
13
|
-
|
|
14
|
-
const ruleName = nonTerminalNode.getRuleName(),
|
|
15
|
-
premiseNonTerminalNodeRuleName = premiseNonTerminalNode.getRuleName(),
|
|
16
|
-
ruleNameStatementRuleName = (ruleName === STATEMENT_RULE_NAME),
|
|
17
|
-
premiseNonTerminalNodeRuleNameMetastatementRuleName = (premiseNonTerminalNodeRuleName === METASTATEMENT_RULE_NAME);
|
|
18
|
-
|
|
19
|
-
if (ruleNameStatementRuleName && premiseNonTerminalNodeRuleNameMetastatementRuleName) {
|
|
20
|
-
const statementNode = nonTerminalNode, ///
|
|
21
|
-
premiseMetastatementNode = premiseNonTerminalNode, ///
|
|
22
|
-
metastatementNodeMatches = this.matchMetastatementNode(premiseMetastatementNode, statementNode, substitutions);
|
|
23
|
-
|
|
24
|
-
if (metastatementNodeMatches) {
|
|
25
|
-
nonTerminalNodeMatches = true;
|
|
26
|
-
} else {
|
|
27
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(premiseNonTerminalNode, nonTerminalNode, substitutions);
|
|
28
|
-
}
|
|
29
|
-
} else if (ruleName === premiseNonTerminalNodeRuleName) {
|
|
30
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(premiseNonTerminalNode, nonTerminalNode, substitutions);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return nonTerminalNodeMatches;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
matchMetavariableNode(premiseMetavariableNode, statementNode, substitutions) {
|
|
37
|
-
let metavariableNodeMatches;
|
|
38
|
-
|
|
39
|
-
const premiseMetavariableName = metavariableNameFromMetavariableNode(premiseMetavariableNode),
|
|
40
|
-
substitution = substitutions.find((substitution) => {
|
|
41
|
-
const metavariableName = substitution.getMetavariableName();
|
|
42
|
-
|
|
43
|
-
if (metavariableName === premiseMetavariableName) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}) || null;
|
|
47
|
-
|
|
48
|
-
if (substitution !== null) {
|
|
49
|
-
const substitutionNodesMatch = substitution.matchStatementNode(statementNode);
|
|
50
|
-
|
|
51
|
-
metavariableNodeMatches = substitutionNodesMatch; ///
|
|
52
|
-
} else {
|
|
53
|
-
const metavariableName = premiseMetavariableName, ///
|
|
54
|
-
substitution = Substitution.fromMetavariableNameAndStatementNode(metavariableName, statementNode);
|
|
55
|
-
|
|
56
|
-
substitutions.push(substitution);
|
|
57
|
-
|
|
58
|
-
metavariableNodeMatches = true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return metavariableNodeMatches;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
matchMetastatementNode(premiseMetastatementNode, statementNode, substitutions) {
|
|
65
|
-
let metastatementNodeMatches = false;
|
|
66
|
-
|
|
67
|
-
const premiseNonTerminalNode = premiseMetastatementNode, ///
|
|
68
|
-
premiseNonTerminalNodeChildNodes = premiseNonTerminalNode.getChildNodes(),
|
|
69
|
-
premiseNonTerminalNodeChildNodesLength = premiseNonTerminalNodeChildNodes.length;
|
|
70
|
-
|
|
71
|
-
if (premiseNonTerminalNodeChildNodesLength === 1) {
|
|
72
|
-
const firstPremiseChildNode = first(premiseNonTerminalNodeChildNodes),
|
|
73
|
-
premiseChildNode = firstPremiseChildNode, ///
|
|
74
|
-
premiseChildNodeNonTerminalNode = premiseChildNode.isNonTerminalNode();
|
|
75
|
-
|
|
76
|
-
if (premiseChildNodeNonTerminalNode) {
|
|
77
|
-
const premiseNonTerminalChildNode = premiseChildNode, ///
|
|
78
|
-
premiseNonTerminalChildNodeRuleName = premiseNonTerminalChildNode.getRuleName(),
|
|
79
|
-
premiseNonTerminalChildNodeRuleNameMetavariableRuleName = (premiseNonTerminalChildNodeRuleName === METAVARIABLE_RULE_NAME);
|
|
80
|
-
|
|
81
|
-
if (premiseNonTerminalChildNodeRuleNameMetavariableRuleName) {
|
|
82
|
-
const premiseMetavariableNode = premiseNonTerminalChildNode, ///
|
|
83
|
-
metaVariableNodeMatches = this.matchMetavariableNode(premiseMetavariableNode, statementNode, substitutions);
|
|
84
|
-
|
|
85
|
-
metastatementNodeMatches = metaVariableNodeMatches; ///
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return metastatementNodeMatches;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const premiseMatcher = new PremiseMatcher();
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Matcher from "../matcher";
|
|
4
|
-
import Substitution from "../substitution";
|
|
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
|
-
class SuppositionMatcher extends Matcher {
|
|
11
|
-
matchNonTerminalNode(suppositionNonTerminalNode, nonTerminalNode, substitutions) {
|
|
12
|
-
let nonTerminalNodeMatches = false;
|
|
13
|
-
|
|
14
|
-
const ruleName = nonTerminalNode.getRuleName(),
|
|
15
|
-
suppositionRuleName = suppositionNonTerminalNode.getRuleName(); ///
|
|
16
|
-
|
|
17
|
-
if (ruleName === suppositionRuleName) {
|
|
18
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(suppositionNonTerminalNode, nonTerminalNode, substitutions);
|
|
19
|
-
|
|
20
|
-
if (!nonTerminalNodeMatches) {
|
|
21
|
-
const ruleNameStatementRuleName = (ruleName === STATEMENT_RULE_NAME);
|
|
22
|
-
|
|
23
|
-
if (ruleNameStatementRuleName) {
|
|
24
|
-
const statementNode = nonTerminalNode, ///
|
|
25
|
-
suppositionStatementNode = suppositionNonTerminalNode, ///
|
|
26
|
-
statementNodeMatches = this.matchStatementNode(suppositionStatementNode, statementNode, substitutions);
|
|
27
|
-
|
|
28
|
-
nonTerminalNodeMatches = statementNodeMatches; ///
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return nonTerminalNodeMatches;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
matchStatementNode(suppositionStatementNode, statementNode, substitutions) {
|
|
37
|
-
let statementNodeMatches = false;
|
|
38
|
-
|
|
39
|
-
const suppositionNonTerminalNode = suppositionStatementNode, ///
|
|
40
|
-
suppositionChildNodes = suppositionNonTerminalNode.getChildNodes(),
|
|
41
|
-
suppositionChildNodesLength = suppositionChildNodes.length;
|
|
42
|
-
|
|
43
|
-
if (suppositionChildNodesLength === 1) {
|
|
44
|
-
const firstSuppositionChildNode = first(suppositionChildNodes),
|
|
45
|
-
suppositionChildNode = firstSuppositionChildNode, ///
|
|
46
|
-
suppositionChildNodeNonTerminalNode = suppositionChildNode.isNonTerminalNode();
|
|
47
|
-
|
|
48
|
-
if (suppositionChildNodeNonTerminalNode) {
|
|
49
|
-
const suppositionNonTerminalChildNode = suppositionChildNode, ///
|
|
50
|
-
suppositionNonTerminalChildNodeRuleName = suppositionNonTerminalChildNode.getRuleName(),
|
|
51
|
-
suppositionNonTerminalChildNodeRuleNameVariableRuleName = (suppositionNonTerminalChildNodeRuleName === VARIABLE_RULE_NAME);
|
|
52
|
-
|
|
53
|
-
if (suppositionNonTerminalChildNodeRuleNameVariableRuleName) {
|
|
54
|
-
const suppositionVariableNode = suppositionNonTerminalChildNode, ///
|
|
55
|
-
nonTerminalNode = statementNode, ///
|
|
56
|
-
childNodes = nonTerminalNode.getChildNodes(),
|
|
57
|
-
nodes = childNodes, ///
|
|
58
|
-
variableMatches = this.matchVariable(suppositionVariableNode, nodes, substitutions);
|
|
59
|
-
|
|
60
|
-
statementNodeMatches = variableMatches; ///
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return statementNodeMatches;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
matchVariable(suppositionVariableNode, nodes, substitutions) {
|
|
69
|
-
let variableMatches;
|
|
70
|
-
|
|
71
|
-
const suppositionVariableName = variableNameFromVariableNode(suppositionVariableNode),
|
|
72
|
-
substitution = substitutions.find((substitution) => {
|
|
73
|
-
const variableName = substitution.getVariableName();
|
|
74
|
-
|
|
75
|
-
if (variableName === suppositionVariableName) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}) || null;
|
|
79
|
-
|
|
80
|
-
if (substitution !== null) {
|
|
81
|
-
const substitutionNodesMatch = substitution.matchNodes(nodes);
|
|
82
|
-
|
|
83
|
-
variableMatches = substitutionNodesMatch; ///
|
|
84
|
-
} else {
|
|
85
|
-
const variableName = suppositionVariableName, ///
|
|
86
|
-
substitution = Substitution.fromVariableNameAndNodes(variableName, nodes);
|
|
87
|
-
|
|
88
|
-
substitutions.push(substitution);
|
|
89
|
-
|
|
90
|
-
variableMatches = true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return variableMatches;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const suppositionMatcher = new SuppositionMatcher();
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import MetaMatcher from "../metaMatcher";
|
|
4
|
-
|
|
5
|
-
import { first } from "../utilities/array";
|
|
6
|
-
import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
7
|
-
import { METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
8
|
-
|
|
9
|
-
class ConclusionMetaMatcher extends MetaMatcher {
|
|
10
|
-
matchNonTerminalNode(conclusionNonTerminalNode, nonTerminalNode, metaSubstitutions) {
|
|
11
|
-
let nonTerminalNodeMatches = false;
|
|
12
|
-
|
|
13
|
-
const ruleName = nonTerminalNode.getRuleName(),
|
|
14
|
-
conclusionNonTerminalNodeRuleName = conclusionNonTerminalNode.getRuleName(),
|
|
15
|
-
ruleNameMetastatementRuleName = (ruleName === METASTATEMENT_RULE_NAME),
|
|
16
|
-
conclusionNonTerminalNodeRuleNameMetastatementRuleName = (conclusionNonTerminalNodeRuleName === METASTATEMENT_RULE_NAME);
|
|
17
|
-
|
|
18
|
-
if (ruleNameMetastatementRuleName && conclusionNonTerminalNodeRuleNameMetastatementRuleName) {
|
|
19
|
-
const statementNode = nonTerminalNode, ///
|
|
20
|
-
conclusionMetastatementNode = conclusionNonTerminalNode, ///
|
|
21
|
-
metastatementNodeMatches = this.matchMetastatementNode(conclusionMetastatementNode, statementNode, metaSubstitutions);
|
|
22
|
-
|
|
23
|
-
if (metastatementNodeMatches) {
|
|
24
|
-
nonTerminalNodeMatches = true; ///
|
|
25
|
-
} else {
|
|
26
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(conclusionNonTerminalNode, nonTerminalNode, metaSubstitutions);
|
|
27
|
-
}
|
|
28
|
-
} else if (ruleName === conclusionNonTerminalNodeRuleName) {
|
|
29
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(conclusionNonTerminalNode, nonTerminalNode, metaSubstitutions);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return nonTerminalNodeMatches;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
matchMetavariableNode(conclusionMetavariableNode, metastatementNode, metaSubstitutions) {
|
|
36
|
-
let metavariableNodeMatches = true;
|
|
37
|
-
|
|
38
|
-
const conclusionMetavariableName = metavariableNameFromMetavariableNode(conclusionMetavariableNode),
|
|
39
|
-
metaSubstitution = metaSubstitutions.find((metaSubstitution) => {
|
|
40
|
-
const metavariableName = metaSubstitution.getMetavariableName();
|
|
41
|
-
|
|
42
|
-
if (metavariableName === conclusionMetavariableName) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}) || null;
|
|
46
|
-
|
|
47
|
-
if (metaSubstitution !== null) {
|
|
48
|
-
const metaSubstitutionNodesMatch = metaSubstitution.matchMetastatementNode(metastatementNode);
|
|
49
|
-
|
|
50
|
-
metavariableNodeMatches = metaSubstitutionNodesMatch; ///
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return metavariableNodeMatches;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
matchMetastatementNode(conclusionMetastatementNode, metastatementNode, metaSubstitutions) {
|
|
57
|
-
let metastatementNodeMatches = false;
|
|
58
|
-
|
|
59
|
-
const conclusionNonTerminalNode = conclusionMetastatementNode, ///
|
|
60
|
-
conclusionNonTerminalNodeChildNodes = conclusionNonTerminalNode.getChildNodes(),
|
|
61
|
-
conclusionNonTerminalNodeChildNodesLength = conclusionNonTerminalNodeChildNodes.length;
|
|
62
|
-
|
|
63
|
-
if (conclusionNonTerminalNodeChildNodesLength === 1) {
|
|
64
|
-
const firstConclusionChildNode = first(conclusionNonTerminalNodeChildNodes),
|
|
65
|
-
conclusionChildNode = firstConclusionChildNode, ///
|
|
66
|
-
conclusionChildNodeNonTerminalNode = conclusionChildNode.isNonTerminalNode();
|
|
67
|
-
|
|
68
|
-
if (conclusionChildNodeNonTerminalNode) {
|
|
69
|
-
const conclusionNonTerminalChildNode = conclusionChildNode, ///
|
|
70
|
-
conclusionNonTerminalChildNodeRuleName = conclusionNonTerminalChildNode.getRuleName(),
|
|
71
|
-
conclusionNonTerminalChildNodeRuleNameMetavariableRuleName = (conclusionNonTerminalChildNodeRuleName === METAVARIABLE_RULE_NAME);
|
|
72
|
-
|
|
73
|
-
if (conclusionNonTerminalChildNodeRuleNameMetavariableRuleName) {
|
|
74
|
-
const conclusionMetavariableNode = conclusionNonTerminalChildNode, ///
|
|
75
|
-
metavariableNodeMatches = this.matchMetavariableNode(conclusionMetavariableNode, metastatementNode, metaSubstitutions);
|
|
76
|
-
|
|
77
|
-
metastatementNodeMatches = metavariableNodeMatches; ///
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return metastatementNodeMatches;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const conclusionMetaMatcher = new ConclusionMetaMatcher();
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import MetaMatcher from "../metaMatcher";
|
|
4
|
-
import MetaSubstitution from "../metaSubstitution";
|
|
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
|
-
class PremiseMetaMatcher extends MetaMatcher {
|
|
11
|
-
matchNonTerminalNode(premiseNonTerminalNode, nonTerminalNode, metaSubstitutions) {
|
|
12
|
-
let nonTerminalNodeMatches = false;
|
|
13
|
-
|
|
14
|
-
const ruleName = nonTerminalNode.getRuleName(),
|
|
15
|
-
premiseNonTerminalNodeRuleName = premiseNonTerminalNode.getRuleName(),
|
|
16
|
-
ruleNameMetastatementRuleName = (ruleName === METASTATEMENT_RULE_NAME),
|
|
17
|
-
premiseNonTerminalNodeRuleNameMetastatementRuleName = (premiseNonTerminalNodeRuleName === METASTATEMENT_RULE_NAME);
|
|
18
|
-
|
|
19
|
-
if (ruleNameMetastatementRuleName && premiseNonTerminalNodeRuleNameMetastatementRuleName) {
|
|
20
|
-
const metastatementNode = nonTerminalNode, ///
|
|
21
|
-
premiseMetastatementNode = premiseNonTerminalNode, ///
|
|
22
|
-
metastatementNodeMatches = this.matchMetastatementNode(premiseMetastatementNode, metastatementNode, metaSubstitutions);
|
|
23
|
-
|
|
24
|
-
if (metastatementNodeMatches) {
|
|
25
|
-
nonTerminalNodeMatches = true;
|
|
26
|
-
} else {
|
|
27
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(premiseNonTerminalNode, nonTerminalNode, metaSubstitutions);
|
|
28
|
-
}
|
|
29
|
-
} else if (ruleName === premiseNonTerminalNodeRuleName) {
|
|
30
|
-
nonTerminalNodeMatches = super.matchNonTerminalNode(premiseNonTerminalNode, nonTerminalNode, metaSubstitutions);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return nonTerminalNodeMatches;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
matchMetavariableNode(premiseMetavariableNode, metastatementNode, metaSubstitutions) {
|
|
37
|
-
let metavariableNodeMatches;
|
|
38
|
-
|
|
39
|
-
const premiseMetavariableName = metavariableNameFromMetavariableNode(premiseMetavariableNode),
|
|
40
|
-
metaSubstitution = metaSubstitutions.find((metaSubstitution) => {
|
|
41
|
-
const metavariableName = metaSubstitution.getMetavariableName();
|
|
42
|
-
|
|
43
|
-
if (metavariableName === premiseMetavariableName) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}) || null;
|
|
47
|
-
|
|
48
|
-
if (metaSubstitution !== null) {
|
|
49
|
-
const metaSubstitutionNodesMatch = metaSubstitution.matchMetastatementNode(metastatementNode);
|
|
50
|
-
|
|
51
|
-
metavariableNodeMatches = metaSubstitutionNodesMatch; ///
|
|
52
|
-
} else {
|
|
53
|
-
const metavariableName = premiseMetavariableName, ///
|
|
54
|
-
metaSubstitution = MetaSubstitution.fromMetavariableNameAndMetastatementNode(metavariableName, metastatementNode);
|
|
55
|
-
|
|
56
|
-
metaSubstitutions.push(metaSubstitution);
|
|
57
|
-
|
|
58
|
-
metavariableNodeMatches = true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return metavariableNodeMatches;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
matchMetastatementNode(premiseMetastatementNode, metastatementNode, metaSubstitutions) {
|
|
65
|
-
let metastatementNodeMatches = false;
|
|
66
|
-
|
|
67
|
-
const premiseNonTerminalNode = premiseMetastatementNode, ///
|
|
68
|
-
premiseNonTerminalNodeChildNodes = premiseNonTerminalNode.getChildNodes(),
|
|
69
|
-
premiseNonTerminalNodeChildNodesLength = premiseNonTerminalNodeChildNodes.length;
|
|
70
|
-
|
|
71
|
-
if (premiseNonTerminalNodeChildNodesLength === 1) {
|
|
72
|
-
const firstPremiseChildNode = first(premiseNonTerminalNodeChildNodes),
|
|
73
|
-
premiseChildNode = firstPremiseChildNode, ///
|
|
74
|
-
premiseChildNodeNonTerminalNode = premiseChildNode.isNonTerminalNode();
|
|
75
|
-
|
|
76
|
-
if (premiseChildNodeNonTerminalNode) {
|
|
77
|
-
const premiseNonTerminalChildNode = premiseChildNode, ///
|
|
78
|
-
premiseNonTerminalChildNodeRuleName = premiseNonTerminalChildNode.getRuleName(),
|
|
79
|
-
premiseNonTerminalChildNodeRuleNameMetavariableRuleName = (premiseNonTerminalChildNodeRuleName === METAVARIABLE_RULE_NAME);
|
|
80
|
-
|
|
81
|
-
if (premiseNonTerminalChildNodeRuleNameMetavariableRuleName) {
|
|
82
|
-
const premiseMetavariableNode = premiseNonTerminalChildNode, ///
|
|
83
|
-
metaVariableNodeMatches = this.matchMetavariableNode(premiseMetavariableNode, metastatementNode, metaSubstitutions);
|
|
84
|
-
|
|
85
|
-
metastatementNodeMatches = metaVariableNodeMatches; ///
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return metastatementNodeMatches;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const premiseMetaMatcher = new PremiseMetaMatcher();
|
package/src/metaMatcher.js
DELETED
package/src/mixins/matcher.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function matchNode(nodeA, nodeB, ...remainingArguments) {
|
|
4
|
-
let nodeMatches = false;
|
|
5
|
-
|
|
6
|
-
const nodeATerminalNode = nodeA.isTerminalNode(),
|
|
7
|
-
nodeBTerminalNode = nodeB.isTerminalNode();
|
|
8
|
-
|
|
9
|
-
if (nodeATerminalNode === nodeBTerminalNode) {
|
|
10
|
-
if (nodeATerminalNode) {
|
|
11
|
-
const terminalNodeA = nodeA, ///
|
|
12
|
-
terminalNodeB = nodeB, ///
|
|
13
|
-
terminalNodeMatches = this.matchTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments);
|
|
14
|
-
|
|
15
|
-
nodeMatches = terminalNodeMatches; ///
|
|
16
|
-
} else {
|
|
17
|
-
const nonTerminalNodeA = nodeA, ///
|
|
18
|
-
nonTerminalNodeB = nodeB, ///
|
|
19
|
-
nonTerminalNodeMatches = this.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments);
|
|
20
|
-
|
|
21
|
-
nodeMatches = nonTerminalNodeMatches; ///
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return nodeMatches;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function matchNodes(nodesA, nodesB, ...remainingArguments) {
|
|
29
|
-
let nodesMatch = false;
|
|
30
|
-
|
|
31
|
-
const nodesALength = nodesA.length,
|
|
32
|
-
nodesBLength = nodesB.length;
|
|
33
|
-
|
|
34
|
-
if (nodesALength === nodesBLength) {
|
|
35
|
-
nodesMatch = nodesA.every((nodeA, index) => {
|
|
36
|
-
const nodeB = nodesB[index],
|
|
37
|
-
nodeMatches = this.matchNode(nodeA, nodeB, ...remainingArguments);
|
|
38
|
-
|
|
39
|
-
if (nodeMatches) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return nodesMatch;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function matchTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments) {
|
|
49
|
-
const matches = terminalNodeA.match(terminalNodeB),
|
|
50
|
-
terminalNodeMatches = matches; ///
|
|
51
|
-
|
|
52
|
-
return terminalNodeMatches;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments) {
|
|
56
|
-
let nonTerminalNodeMatches = false;
|
|
57
|
-
|
|
58
|
-
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(), ///
|
|
59
|
-
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(); ///
|
|
60
|
-
|
|
61
|
-
if (nonTerminalNodeARuleName === nonTerminalNodeBRuleName) {
|
|
62
|
-
const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
63
|
-
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
64
|
-
nodesA = nonTerminalNodeAChildNodes, ///
|
|
65
|
-
nodesB = nonTerminalNodeBChildNodes, ///
|
|
66
|
-
nodesMatch = this.matchNodes(nodesA, nodesB, ...remainingArguments);
|
|
67
|
-
|
|
68
|
-
nonTerminalNodeMatches = nodesMatch; ///
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return nonTerminalNodeMatches;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const matcherMixins = {
|
|
75
|
-
matchNode,
|
|
76
|
-
matchNodes,
|
|
77
|
-
matchTerminalNode,
|
|
78
|
-
matchNonTerminalNode
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export default matcherMixins;
|