occam-verify-cli 0.0.506 → 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 -161
- package/lib/consequence.js +4 -82
- 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 +150 -0
- package/lib/premise.js +21 -190
- package/lib/rule.js +11 -11
- package/lib/ruleNames.js +5 -1
- package/lib/step/metaproof.js +5 -5
- 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 +10 -97
- package/lib/utilities/substitution.js +61 -0
- package/lib/verify/metaproof.js +3 -3
- package/lib/verify/proof.js +3 -3
- package/lib/verify/ruleProof.js +3 -3
- package/package.json +1 -1
- package/src/axiomLemmaTheorem.js +1 -1
- package/src/conclusion.js +11 -282
- package/src/consequence.js +6 -144
- 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 +76 -0
- package/src/premise.js +48 -336
- package/src/rule.js +12 -12
- package/src/ruleNames.js +1 -0
- package/src/step/metaproof.js +1 -1
- package/src/{metaSubstitution.js → substitution/metastatementForMetavariable.js} +9 -8
- package/src/{substitution.js → substitution/statementForMetavariable.js} +8 -7
- package/src/substitution/statementForVariable.js +64 -0
- package/src/supposition.js +26 -173
- package/src/utilities/{node.js → substitution.js} +4 -74
- package/src/verify/metaproof.js +2 -2
- package/src/verify/proof.js +2 -2
- package/src/verify/ruleProof.js +2 -2
- package/lib/metaSubstitution.js +0 -85
- package/lib/metaSupposition.js +0 -167
- package/lib/substitution.js +0 -85
- package/lib/utilities/node.js +0 -106
- package/lib/verify/metaSupposition.js +0 -41
- package/src/metaSupposition.js +0 -196
- package/src/verify/metaSupposition.js +0 -44
|
@@ -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
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default class Matcher {
|
|
4
|
+
matchNode(nodeA, nodeB, ...remainingArguments) {
|
|
5
|
+
let nodeMatches = false;
|
|
6
|
+
|
|
7
|
+
const nodeATerminalNode = nodeA.isTerminalNode(),
|
|
8
|
+
nodeBTerminalNode = nodeB.isTerminalNode();
|
|
9
|
+
|
|
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
|
+
}
|
|
75
|
+
|
|
76
|
+
export const matcher = new Matcher();
|