occam-verify-cli 0.0.269 → 0.0.271
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/bin/assertion.js +145 -0
- package/bin/conclusion.js +67 -41
- package/bin/constants.js +11 -1
- package/bin/context/file.js +9 -3
- package/bin/context/metaproof.js +17 -8
- package/bin/metaAssertion.js +130 -20
- package/bin/metaSubstitution.js +45 -30
- package/bin/permutations.js +3 -0
- package/bin/permutationsMatrix.js +6 -0
- package/bin/premise.js +110 -48
- package/bin/rule.js +36 -28
- package/bin/ruleNames.js +4 -0
- package/bin/utilities/array.js +54 -71
- package/bin/utilities/metastatement.js +44 -0
- package/bin/utilities/permutations.js +148 -0
- package/bin/verify/antecedent.js +7 -18
- package/bin/verify/{typeAssertion.js → assertion/type.js} +4 -4
- package/bin/verify/conditinalInference.js +15 -12
- package/bin/verify/metaAntecedent.js +7 -14
- package/bin/verify/metaDerivation.js +1 -0
- package/bin/verify/metaproof.js +90 -20
- package/bin/verify/metastatement/qualified.js +2 -6
- package/bin/verify/metastatement/unqualified.js +4 -4
- package/bin/verify/rule.js +28 -16
- package/bin/verify/statement.js +1 -1
- package/bin/verify/unconditionalInference.js +9 -5
- package/package.json +3 -3
- package/bin/antecedent.js +0 -19
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { fileSystemUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { push, last, first } = require("../utilities/array"),
|
|
6
|
+
{ MAXIMUM_INDEXES_LENGTH, MAXIMUM_PERMUTATION_LENGTH } = require("../constants");
|
|
7
|
+
|
|
8
|
+
const { writeFile } = fileSystemUtilities;
|
|
9
|
+
|
|
10
|
+
writePermutationsMatrixFile();
|
|
11
|
+
|
|
12
|
+
function permutationsMatrixFromNothing() {
|
|
13
|
+
const permutationsMatrix = [];
|
|
14
|
+
|
|
15
|
+
for (let indexesLength = 0; indexesLength <= MAXIMUM_INDEXES_LENGTH; indexesLength++) {
|
|
16
|
+
const permutationsArray = [];
|
|
17
|
+
|
|
18
|
+
for (let permutationLength = 0; permutationLength <= MAXIMUM_PERMUTATION_LENGTH; permutationLength++) {
|
|
19
|
+
const permutations = ((permutationLength === 0) || (permutationLength > indexesLength)) ?
|
|
20
|
+
null :
|
|
21
|
+
permutationsFromIndexesLengthAndPermutationLength(indexesLength, permutationLength);
|
|
22
|
+
|
|
23
|
+
permutationsArray.push(permutations);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
permutationsMatrix.push(permutationsArray);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return permutationsMatrix;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function writePermutationsMatrixFile() {
|
|
33
|
+
const permutationsMatrix = permutationsMatrixFromNothing(),
|
|
34
|
+
permutationsMatrixJSON = JSON.stringify(permutationsMatrix),
|
|
35
|
+
permutationsMatrixFileName = "./bin/permutationsMatrix.js",
|
|
36
|
+
permutationsMatrixFileContent = `"use strict";
|
|
37
|
+
|
|
38
|
+
const permutationsMatrix = ${permutationsMatrixJSON};
|
|
39
|
+
|
|
40
|
+
module.exports = permutationsMatrix;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
writeFile(permutationsMatrixFileName, permutationsMatrixFileContent)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function permutationsFromChoice(choice) {
|
|
47
|
+
const permutations = [],
|
|
48
|
+
choiceLength = choice.length;
|
|
49
|
+
|
|
50
|
+
if (choiceLength === 1) {
|
|
51
|
+
const permutation = choice.slice();
|
|
52
|
+
|
|
53
|
+
permutations.push(permutation);
|
|
54
|
+
} else {
|
|
55
|
+
const innerChoice = choice.slice(0),
|
|
56
|
+
start = 0,
|
|
57
|
+
deleteCount = 1,
|
|
58
|
+
indexes = innerChoice.splice(start, deleteCount),
|
|
59
|
+
firstIndex = first(indexes),
|
|
60
|
+
innerPermutations = permutationsFromChoice(innerChoice);
|
|
61
|
+
|
|
62
|
+
innerPermutations.forEach((innerPermutation) => {
|
|
63
|
+
for (let position = 0; position < choiceLength; position++) {
|
|
64
|
+
const permutation = innerPermutation.slice(0),
|
|
65
|
+
start = position, ///
|
|
66
|
+
deleteCount = 0;
|
|
67
|
+
|
|
68
|
+
permutation.splice(start, deleteCount, firstIndex);
|
|
69
|
+
|
|
70
|
+
permutations.push(permutation);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return permutations;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function permutationsFromChoices(choices) {
|
|
79
|
+
const permutations = [];
|
|
80
|
+
|
|
81
|
+
choices.forEach((choice) => {
|
|
82
|
+
const choicePermutations = permutationsFromChoice(choice);
|
|
83
|
+
|
|
84
|
+
push(permutations, choicePermutations);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return permutations;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function indexesFromIndexesLength(indexesLength) {
|
|
91
|
+
const indexes = [];
|
|
92
|
+
|
|
93
|
+
for (let index = 0; index < indexesLength; index++) {
|
|
94
|
+
indexes.push(index);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return indexes;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function choicesFromIndexesAndChoiceLength(indexes, choiceLength) {
|
|
101
|
+
const choices = [],
|
|
102
|
+
indexesLength = indexes.length;
|
|
103
|
+
|
|
104
|
+
if (choiceLength === 0) {
|
|
105
|
+
///
|
|
106
|
+
} else if (choiceLength === 1) {
|
|
107
|
+
for (let position = 0; position < indexesLength; position++) {
|
|
108
|
+
const index = indexes[position],
|
|
109
|
+
choice = [
|
|
110
|
+
index
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
choices.push(choice);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
const innerChoiceLength = choiceLength - 1;
|
|
117
|
+
|
|
118
|
+
for (let position = 0; position < indexesLength; position++) {
|
|
119
|
+
const innerIndexes = indexes.slice(0),
|
|
120
|
+
start = 0, ///
|
|
121
|
+
deleteCount = position + 1,
|
|
122
|
+
deletedIndexes = innerIndexes.splice(start, deleteCount),
|
|
123
|
+
lastDeletedIndex = last(deletedIndexes),
|
|
124
|
+
index = lastDeletedIndex, ///
|
|
125
|
+
innerChoices = choicesFromIndexesAndChoiceLength(innerIndexes, innerChoiceLength);
|
|
126
|
+
|
|
127
|
+
innerChoices.forEach((innerChoice) => {
|
|
128
|
+
const choice = [
|
|
129
|
+
index,
|
|
130
|
+
...innerChoice
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
choices.push(choice);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return choices;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function permutationsFromIndexesLengthAndPermutationLength(indexesLength, permutationLength) {
|
|
142
|
+
const choiceLength = permutationLength, ///
|
|
143
|
+
indexes = indexesFromIndexesLength(indexesLength),
|
|
144
|
+
choices = choicesFromIndexesAndChoiceLength(indexes, choiceLength),
|
|
145
|
+
permutations = permutationsFromChoices(choices);
|
|
146
|
+
|
|
147
|
+
return permutations;
|
|
148
|
+
}
|
package/bin/verify/antecedent.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const Assertion = require("../assertion"),
|
|
4
4
|
verifyUnqualifiedStatement = require("../verify/statement/unqualified");
|
|
5
5
|
|
|
6
|
-
const { nodeQuery
|
|
6
|
+
const { nodeQuery } = require("../utilities/query");
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
unqualifiedStatementNodesQuery = nodesQuery("/antecedent/unqualifiedStatement");
|
|
8
|
+
const unqualifiedStatementNodeQuery = nodeQuery("/antecedent/unqualifiedStatement!");
|
|
10
9
|
|
|
11
10
|
function verifyAntecedent(antecedentNode, antecedents, context) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (unqualifiedStatementVerified) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
11
|
+
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(antecedentNode),
|
|
12
|
+
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, context),
|
|
13
|
+
antecedentVerified = unqualifiedStatementVerified;
|
|
20
14
|
|
|
21
15
|
if (antecedentVerified) {
|
|
22
|
-
const
|
|
23
|
-
const statementNode = statementNodeQuery(unqualifiedStatementNode);
|
|
24
|
-
|
|
25
|
-
return statementNode;
|
|
26
|
-
}),
|
|
27
|
-
antecedent = Antecedent.fromStatementNodes(statementNodes);
|
|
16
|
+
const antecedent = Assertion.fromUnqualifiedStatementNode(unqualifiedStatementNode);
|
|
28
17
|
|
|
29
18
|
antecedents.push(antecedent);
|
|
30
19
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const { loggingUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const Variable = require("
|
|
6
|
-
verifyTermAsVariable = require("
|
|
5
|
+
const Variable = require("../../variable"),
|
|
6
|
+
verifyTermAsVariable = require("../../verify/termAsVariable");
|
|
7
7
|
|
|
8
|
-
const { first } = require("
|
|
9
|
-
{ nodeQuery, typeNameFromTypeNode } = require("
|
|
8
|
+
const { first } = require("../../utilities/array"),
|
|
9
|
+
{ nodeQuery, typeNameFromTypeNode } = require("../../utilities/query");
|
|
10
10
|
|
|
11
11
|
const { log } = loggingUtilities;
|
|
12
12
|
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const verifyMetaproof = require("../verify/metaproof"),
|
|
4
|
+
MetaproofContext = require("../context/metaproof"),
|
|
4
5
|
verifyConclusion = require("../verify/conclusion"),
|
|
5
6
|
verifyPremiseOrPremises = require("../verify/premiseOrPremises");
|
|
6
7
|
|
|
7
8
|
const { nodeQuery } = require("../utilities/query");
|
|
9
|
+
const Conclusion = require("../conclusion");
|
|
8
10
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
+
const conclusionNodeQuery = nodeQuery("/conditionalInference/conclusion!"),
|
|
12
|
+
metastatementNodeQuery = nodeQuery("/conditionalInference/conclusion!/unqualifiedMetastatement!/metastatement!"),
|
|
11
13
|
premiseOrPremisesNodeQuery = nodeQuery("/conditionalInference/premise|premises!");
|
|
12
14
|
|
|
13
15
|
function verifyConditionalInference(conditionalInferenceNode, premises, conclusions, context) {
|
|
14
16
|
let conditionalInferenceVerified = false;
|
|
15
17
|
|
|
16
|
-
const
|
|
18
|
+
const metaproofContext = MetaproofContext.fromContext(context);
|
|
19
|
+
|
|
20
|
+
context = metaproofContext; ///
|
|
21
|
+
|
|
22
|
+
const conclusionNode = conclusionNodeQuery(conditionalInferenceNode),
|
|
23
|
+
metastatementNode = metastatementNodeQuery(conditionalInferenceNode),
|
|
24
|
+
premiseOrPremisesNode = premiseOrPremisesNodeQuery(conditionalInferenceNode),
|
|
17
25
|
premiseOrPremisesVerified = verifyPremiseOrPremises(premiseOrPremisesNode, premises, context);
|
|
18
26
|
|
|
19
27
|
if (premiseOrPremisesVerified) {
|
|
20
|
-
const
|
|
21
|
-
conclusionVerified = verifyConclusion(conclusionNode, conclusions, context);
|
|
28
|
+
const conclusionVerified = verifyConclusion(conclusionNode, conclusions, context);
|
|
22
29
|
|
|
23
30
|
if (conclusionVerified) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const metaproofNode = metaproofNodeQuery(conditionalInferenceNode);
|
|
31
|
+
const conclusion = Conclusion.fromMetastatementNode(metastatementNode);
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
metaproofVerified = verifyMetaproof(metaproofNode, context);
|
|
30
|
-
}
|
|
33
|
+
conclusions.push(conclusion);
|
|
31
34
|
|
|
32
|
-
conditionalInferenceVerified =
|
|
35
|
+
conditionalInferenceVerified = true;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -3,26 +3,19 @@
|
|
|
3
3
|
const MetaAssertion = require("../metaAssertion"),
|
|
4
4
|
verifyUnqualifiedMetastatement = require("../verify/metastatement/unqualified");
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { nodeQuery } = require("../utilities/query");
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const unqualifiedMetastatementNodeQuery = nodeQuery("/metaAntecedent/unqualifiedMetastatement!");
|
|
9
9
|
|
|
10
10
|
function verifyMetaAntecedent(metaAntecedentNode, context) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (unqualifiedMetastatementVerified) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
11
|
+
const unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(metaAntecedentNode),
|
|
12
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, context),
|
|
13
|
+
metaAntecedentVerified = unqualifiedMetastatementVerified; ///
|
|
19
14
|
|
|
20
15
|
if (metaAntecedentVerified) {
|
|
21
|
-
|
|
22
|
-
const metaAssertion = MetaAssertion.fromUnqualifiedMetastatementNode(unqualifiedMetastatementNode);
|
|
16
|
+
const metaAssertion = MetaAssertion.fromUnqualifiedMetastatementNode(unqualifiedMetastatementNode);
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
});
|
|
18
|
+
context.addMetaAssertion(metaAssertion);
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
return metaAntecedentVerified;
|
package/bin/verify/metaproof.js
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
const verifyMetaDerivation = require("../verify/metaDerivation"),
|
|
4
4
|
verifyQualifiedMetastatement = require("../verify/metastatement/qualified");
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
{ nodeQuery } = require("../utilities/query"),
|
|
8
|
-
{ nodeAsString } = require("../utilities/string");
|
|
6
|
+
const { nodeQuery } = require("../utilities/query");
|
|
9
7
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const metaDerivationNodeQuery = nodeQuery("/metaproof/metaDerivation!"),
|
|
9
|
+
qualifiedStatementNodeQuery = nodeQuery("/metaproof/qualifiedMetastatement!"),
|
|
10
|
+
metaProofMetastatementNodeQuery = nodeQuery("/metaproof/qualifiedMetastatement/metastatement!");
|
|
13
11
|
|
|
14
|
-
function verifyMetaproof(metaproofNode, context) {
|
|
12
|
+
function verifyMetaproof(metaproofNode, metastatementNode, context) {
|
|
15
13
|
let metaproofVerified = false;
|
|
16
14
|
|
|
17
15
|
const metaDerivationNode = metaDerivationNodeQuery(metaproofNode);
|
|
18
16
|
|
|
19
|
-
let metaDerivationVerified =
|
|
17
|
+
let metaDerivationVerified = true;
|
|
20
18
|
|
|
21
19
|
if (metaDerivationNode !== null) {
|
|
22
20
|
metaDerivationVerified = verifyMetaDerivation(metaDerivationNode, context);
|
|
@@ -27,18 +25,10 @@ function verifyMetaproof(metaproofNode, context) {
|
|
|
27
25
|
qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, context);
|
|
28
26
|
|
|
29
27
|
if (qualifiedMetastatementVerified) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// rule = firstRule, ///
|
|
35
|
-
// metastatementString = nodeAsString(metastatementNode),
|
|
36
|
-
// conclusionMetastatementNode = rule.getConclusionMetastatementNode(),
|
|
37
|
-
// conclusionMetastatementString = nodeAsString(conclusionMetastatementNode);
|
|
38
|
-
//
|
|
39
|
-
// if (metastatementString === conclusionMetastatementString) {
|
|
40
|
-
// metaproofVerified = true;
|
|
41
|
-
// }
|
|
28
|
+
const metaProofMetastatementNode = metaProofMetastatementNodeQuery(metaproofNode),
|
|
29
|
+
metaProofMetastatementNodeMatches = matchMetaProofMetastatementNode(metaProofMetastatementNode, metastatementNode);
|
|
30
|
+
|
|
31
|
+
metaproofVerified = metaProofMetastatementNodeMatches; ///
|
|
42
32
|
}
|
|
43
33
|
}
|
|
44
34
|
|
|
@@ -46,3 +36,83 @@ function verifyMetaproof(metaproofNode, context) {
|
|
|
46
36
|
}
|
|
47
37
|
|
|
48
38
|
module.exports = verifyMetaproof;
|
|
39
|
+
|
|
40
|
+
function matchMetaProofMetastatementNode(metaProofMetastatementNode, metastatementNode) {
|
|
41
|
+
const metaProofNonTerminalNode = metaProofMetastatementNode, ///
|
|
42
|
+
nonTerminalNode = metastatementNode, ///
|
|
43
|
+
metaProofNonTerminalNodeMatches = matchMetaProofNonTerminalNode(metaProofNonTerminalNode, nonTerminalNode),
|
|
44
|
+
metaProofMetastatementNodeMatches = metaProofNonTerminalNodeMatches; ///
|
|
45
|
+
|
|
46
|
+
return metaProofMetastatementNodeMatches;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function matchMetaProofNode(metaProofNode, node) {
|
|
50
|
+
let metaProofNodeMatches = false;
|
|
51
|
+
|
|
52
|
+
const nodeTerminalNode = node.isTerminalNode(),
|
|
53
|
+
ruleNodeTerminalNode = metaProofNode.isTerminalNode();
|
|
54
|
+
|
|
55
|
+
if (nodeTerminalNode === ruleNodeTerminalNode) {
|
|
56
|
+
if (nodeTerminalNode) {
|
|
57
|
+
const terminalNode = node, ///
|
|
58
|
+
metaProofTerminalNode = metaProofNode, ///
|
|
59
|
+
metaProofTerminalNodeMatches = matchMetaProofTerminalNode(metaProofTerminalNode, terminalNode);
|
|
60
|
+
|
|
61
|
+
metaProofNodeMatches = metaProofTerminalNodeMatches; ///
|
|
62
|
+
} else {
|
|
63
|
+
const nonTerminalNode = node, ///
|
|
64
|
+
metaProofNonTerminalNode = metaProofNode, ///
|
|
65
|
+
metaProofNonTerminalNodeMatches = matchMetaProofNonTerminalNode(metaProofNonTerminalNode, nonTerminalNode);
|
|
66
|
+
|
|
67
|
+
metaProofNodeMatches = metaProofNonTerminalNodeMatches; ///
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return metaProofNodeMatches;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function matchMetaProofNodes(metaProofNodes, nodes) {
|
|
75
|
+
let metaProofNodesMatches = false;
|
|
76
|
+
|
|
77
|
+
const nodesLength = nodes.length,
|
|
78
|
+
metaProofNodesLength = metaProofNodes.length;
|
|
79
|
+
|
|
80
|
+
if (nodesLength === metaProofNodesLength) {
|
|
81
|
+
metaProofNodesMatches = nodes.every((node, index) => {
|
|
82
|
+
const metaProofNode = metaProofNodes[index],
|
|
83
|
+
metaProofNodeMatches = matchMetaProofNode(metaProofNode, node);
|
|
84
|
+
|
|
85
|
+
if (metaProofNodeMatches) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return metaProofNodesMatches;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function matchMetaProofTerminalNode(metaProofTerminalNode, terminalNode) {
|
|
95
|
+
const matches = metaProofTerminalNode.match(terminalNode),
|
|
96
|
+
metaProofTerminalNodeMatches = matches; ///
|
|
97
|
+
|
|
98
|
+
return metaProofTerminalNodeMatches;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function matchMetaProofNonTerminalNode(metaProofNonTerminalNode, nonTerminalNode) {
|
|
102
|
+
let metaProofNonTerminalNodeMatches = false;
|
|
103
|
+
|
|
104
|
+
const ruleName = nonTerminalNode.getRuleName(),
|
|
105
|
+
metaProofRuleName = metaProofNonTerminalNode.getRuleName(); ///
|
|
106
|
+
|
|
107
|
+
if (ruleName === metaProofRuleName) {
|
|
108
|
+
const childNodes = nonTerminalNode.getChildNodes(),
|
|
109
|
+
metaProofChildNodes = metaProofNonTerminalNode.getChildNodes(),
|
|
110
|
+
nodes = childNodes, ///
|
|
111
|
+
metaProofNodes = metaProofChildNodes, ///
|
|
112
|
+
metaProofNodesMatches = matchMetaProofNodes(metaProofNodes, nodes);
|
|
113
|
+
|
|
114
|
+
metaProofNonTerminalNodeMatches = metaProofNodesMatches; ///
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return metaProofNonTerminalNodeMatches;
|
|
118
|
+
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { loggingUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const MetaAssertion = require("../../metaAssertion");
|
|
6
|
-
|
|
7
5
|
const { nodeAsString } = require("../../utilities/string"),
|
|
8
6
|
{ nodeQuery, referenceNameFromReferenceNode } = require("../../utilities/query");
|
|
9
7
|
|
|
@@ -25,16 +23,14 @@ function verifyQualifiedMetastatement(qualifiedMetastatementNode, context) {
|
|
|
25
23
|
if (rule !== null) {
|
|
26
24
|
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, context);
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
qualifiedMetastatementVerified = true;
|
|
30
|
-
}
|
|
26
|
+
qualifiedMetastatementVerified = ruleMatchesMetastatement; ///
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
if (qualifiedMetastatementVerified) {
|
|
35
31
|
const metastatementString = nodeAsString(metastatementNode);
|
|
36
32
|
|
|
37
|
-
log.
|
|
33
|
+
log.debug(`Verified the '${metastatementString}' qualified metastatement.`);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
return qualifiedMetastatementVerified;
|
|
@@ -20,10 +20,10 @@ function verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, context) {
|
|
|
20
20
|
const derived = context.isDerived();
|
|
21
21
|
|
|
22
22
|
if (derived) {
|
|
23
|
-
const metaAssertion = MetaAssertion.
|
|
24
|
-
|
|
23
|
+
const metaAssertion = MetaAssertion.fromMetastatementNode(metastatementNode),
|
|
24
|
+
metaAssertionMatches = context.matchMetaAssertion(metaAssertion);
|
|
25
25
|
|
|
26
|
-
unqualifiedMetastatementVerified =
|
|
26
|
+
unqualifiedMetastatementVerified = metaAssertionMatches; ///
|
|
27
27
|
} else {
|
|
28
28
|
unqualifiedMetastatementVerified = true;
|
|
29
29
|
}
|
|
@@ -32,7 +32,7 @@ function verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, context) {
|
|
|
32
32
|
if (unqualifiedMetastatementVerified) {
|
|
33
33
|
const metastatementString = nodeAsString(metastatementNode);
|
|
34
34
|
|
|
35
|
-
log.
|
|
35
|
+
log.debug(`Verified the '${metastatementString}' unqualified metastatement.`);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return unqualifiedMetastatementVerified;
|
package/bin/verify/rule.js
CHANGED
|
@@ -4,7 +4,7 @@ const { loggingUtilities } = require("necessary");
|
|
|
4
4
|
|
|
5
5
|
const Rule = require("../rule"),
|
|
6
6
|
verifyLabels = require("../verify/labels"),
|
|
7
|
-
|
|
7
|
+
verifyMetaproof = require("../verify/metaproof"),
|
|
8
8
|
verifyConditionalInference = require("../verify/conditinalInference"),
|
|
9
9
|
verifyUnconditionalInference = require("../verify/unconditionalInference");
|
|
10
10
|
|
|
@@ -15,6 +15,7 @@ const { first } = require("../utilities/array"),
|
|
|
15
15
|
const { log } = loggingUtilities;
|
|
16
16
|
|
|
17
17
|
const labelNodesQuery = nodesQuery("/rule/label"),
|
|
18
|
+
metaproofNodeQuery = nodeQuery("/rule/metaproof!"),
|
|
18
19
|
conditionalInferenceNodeQuery = nodeQuery("/rule/conditionalInference!"),
|
|
19
20
|
unconditionalInferenceNodeQuery = nodeQuery("/rule/unconditionalInference!");
|
|
20
21
|
|
|
@@ -30,34 +31,45 @@ function verifyRule(ruleNode, context) {
|
|
|
30
31
|
labelsVerified = verifyLabels(labelNodes, labels, context);
|
|
31
32
|
|
|
32
33
|
if (labelsVerified) {
|
|
33
|
-
const metaproofContext = MetaproofContext.fromContext(context);
|
|
34
|
-
|
|
35
|
-
context = metaproofContext; ///
|
|
36
|
-
|
|
37
34
|
const premises = [],
|
|
38
35
|
conclusions = [],
|
|
39
36
|
conditionalInferenceNode = conditionalInferenceNodeQuery(ruleNode),
|
|
40
37
|
unconditionalInferenceNode = unconditionalInferenceNodeQuery(ruleNode);
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
let conditionalInferenceVerified = false,
|
|
40
|
+
unconditionalInferenceVerified = false;
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
if (conditionalInferenceNode !== null) {
|
|
43
|
+
conditionalInferenceVerified = verifyConditionalInference(conditionalInferenceNode, premises, conclusions, context);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
if (unconditionalInferenceNode !== null) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ruleVerified = unconditionalInferenceVerified; ///
|
|
47
|
+
unconditionalInferenceVerified = verifyUnconditionalInference(unconditionalInferenceNode, premises, conclusions, context);
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
if (conditionalInferenceVerified || unconditionalInferenceVerified) {
|
|
51
|
+
const metaproofNode = metaproofNodeQuery(ruleNode),
|
|
52
|
+
firstConclusion = first(conclusions),
|
|
53
|
+
conclusion = firstConclusion; ///
|
|
54
|
+
|
|
55
|
+
let metaproofVerified = true;
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
if (metaproofNode !== null) {
|
|
58
|
+
const metastatementNode = conclusion.getMetastatementNode();
|
|
60
59
|
|
|
60
|
+
metaproofVerified = verifyMetaproof(metaproofNode, metastatementNode, context);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (metaproofVerified) {
|
|
64
|
+
const rule = Rule.fromPremisesConclusionAndLabels(premises, conclusion, labels);
|
|
65
|
+
|
|
66
|
+
context.addRule(rule);
|
|
67
|
+
|
|
68
|
+
ruleVerified = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (ruleVerified) {
|
|
61
73
|
log.info(`Verified the '${labelsString}' rule.`);
|
|
62
74
|
}
|
|
63
75
|
}
|
package/bin/verify/statement.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { loggingUtilities } = require("necessary");
|
|
4
4
|
|
|
5
5
|
const verifyEquality = require("../verify/equality"),
|
|
6
|
-
verifyTypeAssertion = require("../verify/
|
|
6
|
+
verifyTypeAssertion = require("../verify/assertion/type");
|
|
7
7
|
|
|
8
8
|
const { nodeQuery } = require("../utilities/query"),
|
|
9
9
|
{ nodeAsString } = require("../utilities/string");
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const Conclusion = require("../conclusion"),
|
|
4
|
+
MetaproofContext = require("../context/metaproof"),
|
|
4
5
|
verifyUnqualifiedMetastatement = require("../verify/metastatement/unqualified");
|
|
5
6
|
|
|
6
7
|
const { nodeQuery } = require("../utilities/query");
|
|
7
8
|
|
|
8
|
-
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement
|
|
9
|
+
const metastatementNodeQuery = nodeQuery("/unconditionalInference/unqualifiedMetastatement!/metastatement!"),
|
|
9
10
|
unqualifiedMetastatementNodeQuery = nodeQuery("/unconditionalInference/unqualifiedMetastatement!");
|
|
10
11
|
|
|
11
12
|
function verifyUnconditionalInference(unconditionalInferenceNode, premises, conclusions, context) {
|
|
12
13
|
let unconditionalInferenceVerified = false;
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const metaproofContext = MetaproofContext.fromContext(context);
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
context = metaproofContext; ///
|
|
18
|
+
|
|
19
|
+
const metastatementNode = metastatementNodeQuery(unconditionalInferenceNode),
|
|
20
|
+
unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(unconditionalInferenceNode),
|
|
21
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, context);
|
|
17
22
|
|
|
18
23
|
if (unqualifiedMetastatementVerified) {
|
|
19
|
-
const
|
|
20
|
-
conclusion = Conclusion.fromMetastatementNode(metastatementNode);
|
|
24
|
+
const conclusion = Conclusion.fromMetastatementNode(metastatementNode);
|
|
21
25
|
|
|
22
26
|
conclusions.push(conclusion);
|
|
23
27
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occam-verify-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.271",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/occam-verify-cli",
|
|
7
7
|
"description": "Occam's Verifier",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.15",
|
|
14
14
|
"necessary": "^11.0.40",
|
|
15
|
-
"occam-custom-grammars": "^5.0.
|
|
15
|
+
"occam-custom-grammars": "^5.0.352",
|
|
16
16
|
"occam-dom": "^3.0.171",
|
|
17
17
|
"occam-grammar-utilities": "^7.0.66",
|
|
18
|
-
"occam-grammars": "^1.0.
|
|
18
|
+
"occam-grammars": "^1.0.319",
|
|
19
19
|
"occam-open-cli": "^5.0.37",
|
|
20
20
|
"occam-parsers": "^16.0.122"
|
|
21
21
|
},
|
package/bin/antecedent.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
class Antecedent {
|
|
4
|
-
constructor(statementNodes) {
|
|
5
|
-
this.statementNodes = statementNodes;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
getStatementNodes() {
|
|
9
|
-
return this.statementNodes;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static fromStatementNodes(statementNodes) {
|
|
13
|
-
const antecedent = new Antecedent(statementNodes);
|
|
14
|
-
|
|
15
|
-
return antecedent;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = Antecedent;
|