occam-verify-cli 0.0.921 → 0.0.923
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/axiomLemmaTheoremConjecture.js +3 -4
- package/lib/conclusion.js +13 -43
- package/lib/constants.js +1 -5
- package/lib/context/local.js +386 -0
- package/lib/declaration.js +15 -15
- package/lib/metaLemmaMetatheorem.js +59 -59
- package/lib/mixins/context.js +17 -13
- package/lib/mixins/nodesVerifier/metaLevel.js +6 -6
- package/lib/premise.js +16 -94
- package/lib/{step/proof.js → proofStep.js} +1 -1
- package/lib/rule.js +1 -45
- package/lib/ruleNames.js +1 -9
- package/lib/substitution/statementForMetavariable.js +9 -1
- package/lib/substitution.js +1 -8
- package/lib/supposition.js +55 -1
- package/lib/utilities/customGrammar.js +2 -2
- package/lib/utilities/match.js +13 -50
- package/lib/utilities/node.js +2 -27
- package/lib/utilities/tokens.js +1 -8
- package/lib/utilities/verify.js +8 -24
- package/lib/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +29 -29
- package/lib/verifier/nodes/metaLevel.js +13 -13
- package/lib/verify/axiom.js +3 -3
- package/lib/verify/conclusion.js +10 -11
- package/lib/verify/conjecture.js +3 -3
- package/lib/verify/declaration.js +6 -6
- package/lib/verify/lemma.js +3 -3
- package/lib/verify/metaLemma.js +13 -13
- package/lib/verify/metastatement.js +64 -64
- package/lib/verify/metatheorem.js +13 -13
- package/lib/verify/premise.js +11 -30
- package/lib/verify/proof.js +3 -4
- package/lib/verify/proofStep.js +5 -5
- package/lib/verify/rule.js +11 -11
- package/lib/verify/statement/qualified.js +35 -9
- package/lib/verify/statement/unqualified.js +1 -1
- package/lib/verify/subproof.js +3 -4
- package/lib/verify/supposition.js +3 -3
- package/lib/verify/termAsConstructor.js +3 -3
- package/lib/verify/theorem.js +3 -3
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +2 -4
- package/src/conclusion.js +15 -54
- package/src/constants.js +0 -1
- package/src/context/{local/intrinsicLevel.js → local.js} +182 -97
- package/src/declaration.js +19 -19
- package/src/metaLemmaMetatheorem.js +58 -58
- package/src/mixins/context.js +12 -9
- package/src/mixins/nodesVerifier/metaLevel.js +8 -8
- package/src/premise.js +25 -143
- package/src/rule.js +0 -67
- package/src/ruleNames.js +0 -2
- package/src/substitution/statementForMetavariable.js +14 -0
- package/src/substitution.js +0 -6
- package/src/supposition.js +46 -0
- package/src/utilities/customGrammar.js +1 -2
- package/src/utilities/match.js +13 -60
- package/src/utilities/node.js +3 -32
- package/src/utilities/tokens.js +0 -8
- package/src/utilities/verify.js +4 -20
- package/src/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +36 -37
- package/src/verifier/nodes/metaLevel.js +17 -17
- package/src/verify/axiom.js +3 -4
- package/src/verify/conclusion.js +9 -13
- package/src/verify/conjecture.js +3 -4
- package/src/verify/declaration.js +7 -7
- package/src/verify/lemma.js +3 -4
- package/src/verify/metaLemma.js +24 -25
- package/src/verify/metastatement.js +64 -64
- package/src/verify/metatheorem.js +23 -24
- package/src/verify/premise.js +14 -46
- package/src/verify/proof.js +2 -4
- package/src/verify/proofStep.js +1 -1
- package/src/verify/rule.js +11 -12
- package/src/verify/statement/qualified.js +43 -9
- package/src/verify/statement/unqualified.js +1 -1
- package/src/verify/subproof.js +2 -4
- package/src/verify/supposition.js +1 -1
- package/src/verify/termAsConstructor.js +3 -4
- package/src/verify/theorem.js +3 -4
- package/lib/context/local/intrinsicLevel.js +0 -326
- package/lib/context/local/metaLevel.js +0 -282
- package/lib/metaConsequent.js +0 -108
- package/lib/metaSupposition.js +0 -160
- package/lib/node/metastatement/bracketed.js +0 -16
- package/lib/step/metaproof.js +0 -106
- package/lib/substitution/metastatementForMetavariable.js +0 -173
- package/lib/verify/metaConsequent.js +0 -50
- package/lib/verify/metaDerivation.js +0 -31
- package/lib/verify/metaSubDerivation.js +0 -25
- package/lib/verify/metaSubproof.js +0 -35
- package/lib/verify/metaSupposition.js +0 -61
- package/lib/verify/metaSuppositions.js +0 -28
- package/lib/verify/metaproof.js +0 -32
- package/lib/verify/metaproofStep.js +0 -98
- package/lib/verify/metastatement/qualified.js +0 -95
- package/lib/verify/metastatement/unqualified.js +0 -37
- package/lib/verify/metastatementAsContainedAssertion.js +0 -109
- package/lib/verify/metastatementAsDefinedAssertion.js +0 -132
- package/lib/verify/metavariableAgainstMetastatement.js +0 -44
- package/src/context/local/metaLevel.js +0 -191
- package/src/metaConsequent.js +0 -83
- package/src/metaSupposition.js +0 -127
- package/src/node/metastatement/bracketed.js +0 -9
- package/src/step/metaproof.js +0 -73
- package/src/substitution/metastatementForMetavariable.js +0 -90
- package/src/verify/metaConsequent.js +0 -61
- package/src/verify/metaDerivation.js +0 -23
- package/src/verify/metaSubDerivation.js +0 -22
- package/src/verify/metaSubproof.js +0 -34
- package/src/verify/metaSupposition.js +0 -78
- package/src/verify/metaSuppositions.js +0 -17
- package/src/verify/metaproof.js +0 -30
- package/src/verify/metaproofStep.js +0 -137
- package/src/verify/metastatement/qualified.js +0 -130
- package/src/verify/metastatement/unqualified.js +0 -34
- package/src/verify/metastatementAsContainedAssertion.js +0 -127
- package/src/verify/metastatementAsDefinedAssertion.js +0 -156
- package/src/verify/metavariableAgainstMetastatement.js +0 -42
- /package/src/{step/proof.js → proofStep.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Label from "./label";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import Consequent from "./consequent";
|
|
5
|
+
import Supposition from "./supposition";
|
|
6
|
+
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
7
7
|
|
|
8
8
|
import { reverse, correlate } from "./utilities/array";
|
|
9
9
|
|
|
10
10
|
export default class MetaLemmaMetatheorem {
|
|
11
|
-
constructor(labels,
|
|
11
|
+
constructor(labels, suppositions, consequent, substitutions, fileContext) {
|
|
12
12
|
this.labels = labels;
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
13
|
+
this.suppositions = suppositions;
|
|
14
|
+
this.consequent = consequent;
|
|
15
15
|
this.substitutions = substitutions;
|
|
16
16
|
this.fileContext = fileContext;
|
|
17
17
|
}
|
|
@@ -20,12 +20,12 @@ export default class MetaLemmaMetatheorem {
|
|
|
20
20
|
return this.labels;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
return this.
|
|
23
|
+
getSuppositions() {
|
|
24
|
+
return this.suppositions;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
return this.
|
|
27
|
+
getConsequent() {
|
|
28
|
+
return this.consequent;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
getSubstitutions() {
|
|
@@ -36,20 +36,20 @@ export default class MetaLemmaMetatheorem {
|
|
|
36
36
|
return this.fileContext;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
let
|
|
39
|
+
matchStatement(statementNode, localContext) {
|
|
40
|
+
let statementNatches = false;
|
|
41
41
|
|
|
42
42
|
const metaproofSteps = localContext.getProofSteps(),
|
|
43
43
|
substitutions = [],
|
|
44
|
-
|
|
44
|
+
suppositionsMatch = matchSuppositions(this.suppositions, metaproofSteps, substitutions, this.fileContext, localContext);
|
|
45
45
|
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
46
|
+
if (suppositionsMatch) {
|
|
47
|
+
const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.fileContext, localContext);
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
statementNatches = consequentMatches; ///
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
return
|
|
52
|
+
return statementNatches;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
matchMetavariableNode(metavariableNode) {
|
|
@@ -70,12 +70,12 @@ export default class MetaLemmaMetatheorem {
|
|
|
70
70
|
|
|
71
71
|
return labelJSON;
|
|
72
72
|
}),
|
|
73
|
-
|
|
74
|
-
const
|
|
73
|
+
suppositionsJSON = this.suppositions.map((supposition) => {
|
|
74
|
+
const suppositionJSON = supposition.toJSON(tokens);
|
|
75
75
|
|
|
76
|
-
return
|
|
76
|
+
return suppositionJSON;
|
|
77
77
|
}),
|
|
78
|
-
|
|
78
|
+
consequentJSON = this.consequent.toJSON(tokens),
|
|
79
79
|
substitutionsJSON = this.substitutions.map((substitution) => {
|
|
80
80
|
const substitutionJSON = substitution.toJSON();
|
|
81
81
|
|
|
@@ -83,14 +83,14 @@ export default class MetaLemmaMetatheorem {
|
|
|
83
83
|
}),
|
|
84
84
|
localContextJSON = this.fileContext.toJSON(tokens),
|
|
85
85
|
labels = labelsJSON, ///
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
suppositions = suppositionsJSON, ///
|
|
87
|
+
consequent = consequentJSON, ///
|
|
88
88
|
substitutions = substitutionsJSON, ///
|
|
89
89
|
fileContext = localContextJSON, ///
|
|
90
90
|
json = {
|
|
91
91
|
labels,
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
suppositions,
|
|
93
|
+
consequent,
|
|
94
94
|
substitutions,
|
|
95
95
|
fileContext
|
|
96
96
|
};
|
|
@@ -110,79 +110,79 @@ export default class MetaLemmaMetatheorem {
|
|
|
110
110
|
return label;
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
let {
|
|
113
|
+
let { suppositions, consequent, substitutions } = json;
|
|
114
114
|
|
|
115
|
-
const
|
|
115
|
+
const suppositionsJSON = suppositions; ///
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
const json =
|
|
119
|
-
|
|
117
|
+
suppositions = suppositionsJSON.map((suppositionJSON) => {
|
|
118
|
+
const json = suppositionJSON, ///
|
|
119
|
+
supposition = Supposition.fromJSONAndFileContext(json, fileContext);
|
|
120
120
|
|
|
121
|
-
return
|
|
121
|
+
return supposition;
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
const
|
|
124
|
+
const consequentJSON = consequent; ///
|
|
125
125
|
|
|
126
|
-
json =
|
|
126
|
+
json = consequentJSON; ///
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
consequent = Consequent.fromJSONAndFileContext(json, fileContext);
|
|
129
129
|
|
|
130
130
|
const substitutionsJSON = substitutions; ///
|
|
131
131
|
|
|
132
132
|
substitutions = substitutionsJSON.map((substitutionJSON) => {
|
|
133
133
|
const json = substitutionJSON, ///
|
|
134
|
-
|
|
135
|
-
substitution =
|
|
134
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromJSONAndFileContext(json, fileContext),
|
|
135
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
136
136
|
|
|
137
137
|
return substitution;
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
return new Class(labels,
|
|
140
|
+
return new Class(labels, suppositions, consequent, substitutions, fileContext); ///
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
static
|
|
143
|
+
static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Class, labels, suppositions, consequent, substitutions, fileContext) { return new Class(labels, suppositions, consequent, substitutions, fileContext); }
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
function
|
|
147
|
-
|
|
146
|
+
function matchSuppositions(suppositions, metaproofSteps, substitutions, fileContext, localContext) {
|
|
147
|
+
suppositions = reverse(suppositions); ///
|
|
148
148
|
|
|
149
149
|
metaproofSteps = reverse(metaproofSteps); ///
|
|
150
150
|
|
|
151
|
-
const
|
|
152
|
-
const
|
|
151
|
+
const suppositionsMatch = correlate(suppositions, metaproofSteps, (supposition, metaproofStep) => {
|
|
152
|
+
const suppositionMatches = matchSupposition(supposition, metaproofStep, substitutions, fileContext, localContext);
|
|
153
153
|
|
|
154
|
-
if (
|
|
154
|
+
if (suppositionMatches) {
|
|
155
155
|
return true;
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
return
|
|
159
|
+
return suppositionsMatch;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
function
|
|
163
|
-
let
|
|
162
|
+
function matchSupposition(supposition, metaproofStep, substitutions, fileContext, localContext) {
|
|
163
|
+
let matchesSupposition = false;
|
|
164
164
|
|
|
165
|
-
const metaSubproofNode = metaproofStep.
|
|
166
|
-
|
|
165
|
+
const metaSubproofNode = metaproofStep.getSubproofNode(),
|
|
166
|
+
statementNode = metaproofStep.getStatementNode();
|
|
167
167
|
|
|
168
168
|
if (metaSubproofNode !== null) {
|
|
169
|
-
const
|
|
169
|
+
const suppositionMatchesSubproofNode = supposition.matchSubproofNode(metaSubproofNode, substitutions, fileContext, localContext);
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
matchesSupposition - suppositionMatchesSubproofNode; ///
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
174
|
+
if (statementNode !== null) {
|
|
175
|
+
const suppositionMatchesStatementNode = supposition.matchStatementNode(statementNode, substitutions, fileContext, localContext);
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
matchesSupposition - suppositionMatchesStatementNode; ///
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
return
|
|
180
|
+
return matchesSupposition;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
function
|
|
184
|
-
const
|
|
185
|
-
|
|
183
|
+
function matchConsequent(consequent, statementNode, substitutions, fileContext, localContext) {
|
|
184
|
+
const consequentMatchesStatementNode = consequent.matchStatementNode(statementNode, substitutions, fileContext, localContext),
|
|
185
|
+
consequentMatches = consequentMatchesStatementNode; ///
|
|
186
186
|
|
|
187
|
-
return
|
|
187
|
+
return consequentMatches;
|
|
188
188
|
}
|
package/src/mixins/context.js
CHANGED
|
@@ -24,12 +24,6 @@ function getCombinators() { return this.context.getCombinators(); }
|
|
|
24
24
|
|
|
25
25
|
function getConstructors() { return this.context.getConstructors(); }
|
|
26
26
|
|
|
27
|
-
function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
28
|
-
|
|
29
|
-
function findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
30
|
-
|
|
31
|
-
function findMetavariableByName(name) { return this.context.findMetavariableByName(name); }
|
|
32
|
-
|
|
33
27
|
function isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
|
|
34
28
|
|
|
35
29
|
function isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentByTypeNode(typeNode); }
|
|
@@ -38,8 +32,16 @@ function isMetavariablePresentByName(name) { return this.context.isMetavariableP
|
|
|
38
32
|
|
|
39
33
|
function isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
40
34
|
|
|
35
|
+
function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
36
|
+
|
|
37
|
+
function findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
38
|
+
|
|
39
|
+
function findMetavariableByName(name) { return this.context.findMetavariableByName(name); }
|
|
40
|
+
|
|
41
41
|
function findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
42
42
|
|
|
43
|
+
function findMetaTypeByMetaTypeNode(metaTypeNode) { return this.context.findMetaTypeByMetaTypeNode(metaTypeNode); }
|
|
44
|
+
|
|
43
45
|
function findRuleByMetavariableNode(metavariableNode) { return this.context.findRuleByMetavariableNode(metavariableNode); }
|
|
44
46
|
|
|
45
47
|
function findAxiomByMetavariableNode(metavariableNode) { return this.context.findAxiomByMetavariableNode(metavariableNode); }
|
|
@@ -71,14 +73,15 @@ const contextMixins = {
|
|
|
71
73
|
getConjectures,
|
|
72
74
|
getCombinators,
|
|
73
75
|
getConstructors,
|
|
74
|
-
findTypeByTypeName,
|
|
75
|
-
findTypeByTypeNode,
|
|
76
|
-
findMetavariableByName,
|
|
77
76
|
isTypePresentByTypeName,
|
|
78
77
|
isTypePresentByTypeNode,
|
|
79
78
|
isMetavariablePresentByName,
|
|
80
79
|
isLabelPresentByMetavariableNode,
|
|
80
|
+
findTypeByTypeName,
|
|
81
|
+
findTypeByTypeNode,
|
|
82
|
+
findMetavariableByName,
|
|
81
83
|
findLabelByMetavariableNode,
|
|
84
|
+
findMetaTypeByMetaTypeNode,
|
|
82
85
|
findRuleByMetavariableNode,
|
|
83
86
|
findAxiomByMetavariableNode,
|
|
84
87
|
findLemmaByMetavariableNode,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import StatementForMetavariableSubstitution from "../../substitution/statementForMetavariable";
|
|
4
4
|
|
|
5
|
-
function verifyMetavariableNode(metavariableNodeA,
|
|
5
|
+
function verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, localContextA, localMetaContextB, verifyAhead) {
|
|
6
6
|
let metavariableNodeVerified;
|
|
7
7
|
|
|
8
8
|
const substitution = substitutions.find((substitution) => {
|
|
@@ -14,15 +14,15 @@ function verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitut
|
|
|
14
14
|
}) || null;
|
|
15
15
|
|
|
16
16
|
if (substitution !== null) {
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const statementNode = statementNodeB, ///
|
|
18
|
+
substitutionStatementNode = substitution.matchStatementNode(statementNode);
|
|
19
19
|
|
|
20
|
-
metavariableNodeVerified =
|
|
20
|
+
metavariableNodeVerified = substitutionStatementNode; ///
|
|
21
21
|
} else {
|
|
22
22
|
const metavariableNode = metavariableNodeA, ///
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
substitution =
|
|
23
|
+
statementNode = statementNodeB, ///
|
|
24
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode),
|
|
25
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
26
26
|
|
|
27
27
|
substitutions.push(substitution);
|
|
28
28
|
|
package/src/premise.js
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import LocalContext from "./context/local";
|
|
4
4
|
import metaLevelNodesVerifier from "./verifier/nodes/metaLevel";
|
|
5
|
-
import IntrinsicLevelLocalContext from "./context/local/intrinsicLevel";
|
|
6
5
|
import intrinsicLevelAgainstMetaLevelNodesVerifier from "./verifier/nodes/intrinsicLevelAgainstMetaLevel";
|
|
7
6
|
|
|
8
7
|
import { match } from "./utilities/array";
|
|
9
8
|
import { nodeAsString } from "./utilities/string";
|
|
10
9
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
11
|
-
import { statementNodeFromStatementString
|
|
10
|
+
import { statementNodeFromStatementString } from "./utilities/node";
|
|
12
11
|
|
|
13
|
-
const subproofAssertionNodeQuery = nodeQuery("/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ruleSubproofPremiseMetastatementNodesQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
18
|
-
metaSubproofMetaSuppositionMetastatementNodesQuery = nodesQuery("/metaSubproof/metaSupposition/unqualifiedMetastatement!/metastatement!"),
|
|
19
|
-
ruleSubproofLastRuleProofStepMetastatementNodeQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/lastRuleProofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!"),
|
|
20
|
-
metaSubproofLastMetaproofStepMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/lastMetaproofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!");
|
|
12
|
+
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
13
|
+
subproofPremiseStatementNodesQuery = nodesQuery("/subproof/premise/unqualifiedStatement!/statement!"),
|
|
14
|
+
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
15
|
+
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
21
16
|
|
|
22
17
|
export default class Premise {
|
|
23
|
-
constructor(
|
|
24
|
-
this.metastatementNode = metastatementNode;
|
|
18
|
+
constructor(statementNode) {
|
|
25
19
|
this.statementnode = statementNode;
|
|
26
20
|
}
|
|
27
21
|
|
|
28
|
-
getMetastatementNode() {
|
|
29
|
-
return this.metastatementNode;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
22
|
getStatementNode() {
|
|
33
23
|
return this.statementnode;
|
|
34
24
|
}
|
|
@@ -36,11 +26,11 @@ export default class Premise {
|
|
|
36
26
|
matchStatementNode(statementNode, substitutions, fileContext, localContext) {
|
|
37
27
|
let matchesStatementNode = false;
|
|
38
28
|
|
|
39
|
-
if (this.
|
|
40
|
-
const
|
|
41
|
-
nonTerminalNodeA = this.
|
|
29
|
+
if (this.statementNode !== null) {
|
|
30
|
+
const fileContextA = fileContext, ///
|
|
31
|
+
nonTerminalNodeA = this.statementNode, ///
|
|
42
32
|
nonTerminalNodeB = statementNode, ///
|
|
43
|
-
localContextA =
|
|
33
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
44
34
|
localContextB = localContext, ///
|
|
45
35
|
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
46
36
|
const verifiedAhead = true;
|
|
@@ -57,97 +47,23 @@ export default class Premise {
|
|
|
57
47
|
matchSubproofNode(subproofNode, substitutions, fileContext, localContext) {
|
|
58
48
|
let matchesSubproofNode = false;
|
|
59
49
|
|
|
60
|
-
if (this.
|
|
61
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.
|
|
50
|
+
if (this.statementNode !== null) {
|
|
51
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
62
52
|
|
|
63
53
|
if (subproofAssertionNode !== null) {
|
|
64
|
-
const
|
|
54
|
+
const subproofPremiseStatementNodes = subproofPremiseStatementNodesQuery(subproofNode),
|
|
65
55
|
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
66
56
|
subproofStatementNodes = [
|
|
67
|
-
...
|
|
57
|
+
...subproofPremiseStatementNodes,
|
|
68
58
|
subproofLastProofStepStatementNode
|
|
69
59
|
],
|
|
70
|
-
|
|
60
|
+
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode);
|
|
71
61
|
|
|
72
|
-
matchesSubproofNode = match(
|
|
73
|
-
const
|
|
74
|
-
nonTerminalNodeA =
|
|
62
|
+
matchesSubproofNode = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
|
|
63
|
+
const fileContextA = fileContext, ///
|
|
64
|
+
nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
75
65
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
76
|
-
localContextA =
|
|
77
|
-
localContextB = localContext, ///
|
|
78
|
-
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
79
|
-
const verifiedAhead = true;
|
|
80
|
-
|
|
81
|
-
return verifiedAhead;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (nonTerminalNodeVerified) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return matchesSubproofNode;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localContext) {
|
|
95
|
-
let matchesRuleSubproofNode = false;
|
|
96
|
-
|
|
97
|
-
if (this.metastatementNode !== null) {
|
|
98
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
99
|
-
|
|
100
|
-
if (subproofAssertionNode !== null) {
|
|
101
|
-
const ruleSubproofPremiseMetastatementNodes = ruleSubproofPremiseMetastatementNodesQuery(ruleSubproofNode),
|
|
102
|
-
ruleSubproofLastRuleProofStepMetastatementNode = ruleSubproofLastRuleProofStepMetastatementNodeQuery(ruleSubproofNode),
|
|
103
|
-
ruleSubproofMetastatementNodes = [
|
|
104
|
-
...ruleSubproofPremiseMetastatementNodes,
|
|
105
|
-
ruleSubproofLastRuleProofStepMetastatementNode
|
|
106
|
-
],
|
|
107
|
-
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
108
|
-
|
|
109
|
-
matchesRuleSubproofNode = match(subproofAssertionMetastatementNodes, ruleSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
110
|
-
const metaLevelLocalContext = MetaLevelLocalContext.fromFileContext(fileContext),
|
|
111
|
-
nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
112
|
-
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
113
|
-
localContextA = metaLevelLocalContext, ///
|
|
114
|
-
localContextB = localContext, ///
|
|
115
|
-
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
116
|
-
const verifiedAhead = true;
|
|
117
|
-
|
|
118
|
-
return verifiedAhead;
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
if (nonTerminalNodeVerified) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return matchesRuleSubproofNode;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localContext) {
|
|
132
|
-
let matchesMetaSubproofNode = false;
|
|
133
|
-
|
|
134
|
-
if (this.metastatementNode !== null) {
|
|
135
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
136
|
-
|
|
137
|
-
if (subproofAssertionNode !== null) {
|
|
138
|
-
const metaSubproofMetaSuppositionMetastatementNodes = metaSubproofMetaSuppositionMetastatementNodesQuery(metaSubproofNode),
|
|
139
|
-
metaSubproofLastMetaproofStepMetastatementNode = metaSubproofLastMetaproofStepMetastatementNodeQuery(metaSubproofNode),
|
|
140
|
-
metaSubproofMetastatementNodes = [
|
|
141
|
-
...metaSubproofMetaSuppositionMetastatementNodes,
|
|
142
|
-
metaSubproofLastMetaproofStepMetastatementNode
|
|
143
|
-
],
|
|
144
|
-
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
145
|
-
|
|
146
|
-
matchesMetaSubproofNode = match(subproofAssertionMetastatementNodes, metaSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
147
|
-
const metaLevelLocalContext = MetaLevelLocalContext.fromFileContext(fileContext),
|
|
148
|
-
nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
149
|
-
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
150
|
-
localContextA = metaLevelLocalContext, ///
|
|
66
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
151
67
|
localContextB = localContext, ///
|
|
152
68
|
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
153
69
|
const verifiedAhead = true;
|
|
@@ -162,37 +78,13 @@ export default class Premise {
|
|
|
162
78
|
}
|
|
163
79
|
}
|
|
164
80
|
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext) {
|
|
169
|
-
let matchesMetastatementNode = false;
|
|
170
|
-
|
|
171
|
-
if (this.metastatementNode !== null) {
|
|
172
|
-
const metaLevelLocalContext = MetaLevelLocalContext.fromFileContext(fileContext),
|
|
173
|
-
nonTerminalNodeA = this.metastatementNode, ///
|
|
174
|
-
nonTerminalNodeB = metastatementNode, ///
|
|
175
|
-
localContextA = metaLevelLocalContext, ///
|
|
176
|
-
localContextB = localContext, ///
|
|
177
|
-
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
178
|
-
const verifiedAhead = true;
|
|
179
|
-
|
|
180
|
-
return verifiedAhead;
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
matchesMetastatementNode = nonTerminalNodeVerified; ///
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return matchesMetastatementNode;
|
|
81
|
+
return matchesSubproofNode;
|
|
187
82
|
}
|
|
188
83
|
|
|
189
84
|
toJSON(tokens) {
|
|
190
|
-
const
|
|
191
|
-
statementString = nodeAsString(this.statementnode, tokens),
|
|
192
|
-
metastatement = metastatementString, ///
|
|
85
|
+
const statementString = nodeAsString(this.statementnode, tokens),
|
|
193
86
|
statement = statementString, ///
|
|
194
87
|
json = {
|
|
195
|
-
metastatement,
|
|
196
88
|
statement
|
|
197
89
|
};
|
|
198
90
|
|
|
@@ -200,28 +92,18 @@ export default class Premise {
|
|
|
200
92
|
}
|
|
201
93
|
|
|
202
94
|
static fromStatementNode(statementNode) {
|
|
203
|
-
const
|
|
204
|
-
premise = new Premise(metastatementNode, statementNode);
|
|
205
|
-
|
|
206
|
-
return premise;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
static fromMetastatementNode(metastatementNode) {
|
|
210
|
-
const statementNode = null,
|
|
211
|
-
premise = new Premise(metastatementNode, statementNode);
|
|
95
|
+
const premise = new Premise(statementNode);
|
|
212
96
|
|
|
213
97
|
return premise;
|
|
214
98
|
}
|
|
215
99
|
|
|
216
100
|
static fromJSONAndFileContext(json, fileContext) {
|
|
217
|
-
const {
|
|
218
|
-
metastatementString = metastatement, ///
|
|
101
|
+
const { statement } = json,
|
|
219
102
|
statementString = statement, ///
|
|
220
103
|
lexer = fileContext.getLexer(),
|
|
221
104
|
parser = fileContext.getParser(),
|
|
222
|
-
metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
|
|
223
105
|
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
224
|
-
premise = new Premise(
|
|
106
|
+
premise = new Premise(statementNode, statementNode);
|
|
225
107
|
|
|
226
108
|
return premise;
|
|
227
109
|
}
|
package/src/rule.js
CHANGED
|
@@ -46,22 +46,6 @@ export default class Rule {
|
|
|
46
46
|
return matchesStatement;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
matchMetastatement(metastatementNode, localContext) {
|
|
50
|
-
let matchesMetastatement = false;
|
|
51
|
-
|
|
52
|
-
const metaproofSteps = localContext.getMetaproofSteps(),
|
|
53
|
-
substitutions = [],
|
|
54
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, localContext);
|
|
55
|
-
|
|
56
|
-
if (premisesMatch) {
|
|
57
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localContext);
|
|
58
|
-
|
|
59
|
-
matchesMetastatement = conclusionMatches; ///
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return matchesMetastatement;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
49
|
matchMetavariableNode(metavariableNode) {
|
|
66
50
|
const matchesMetavariableNode = this.labels.some((label) => {
|
|
67
51
|
const labelMatchesMetavariableNode = label.matchMetavariableNode(metavariableNode);
|
|
@@ -186,54 +170,3 @@ function matchConclusion(conclusion, statementNode, substitutions, fileContext,
|
|
|
186
170
|
|
|
187
171
|
return conclusionMatches;
|
|
188
172
|
}
|
|
189
|
-
|
|
190
|
-
function metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localContext) {
|
|
191
|
-
let premiseMatches = false;
|
|
192
|
-
|
|
193
|
-
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
194
|
-
metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
195
|
-
metastatementNode = metaproofStep.getMetastatementNode()
|
|
196
|
-
|
|
197
|
-
if (ruleSubproofNode !== null) {
|
|
198
|
-
const premiseMatchesRuleSubproofNode = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localContext);
|
|
199
|
-
|
|
200
|
-
premiseMatches = premiseMatchesRuleSubproofNode; ///
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (metaSubproofNode !== null) {
|
|
204
|
-
const premiseMatchesMetaSubproofNode = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localContext);
|
|
205
|
-
|
|
206
|
-
premiseMatches = premiseMatchesMetaSubproofNode; ///
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (metastatementNode !== null) {
|
|
210
|
-
const premiseMatchesMetastatementNode = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext);
|
|
211
|
-
|
|
212
|
-
premiseMatches = premiseMatchesMetastatementNode; ///
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return premiseMatches;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function metaMatchPremises(premises, metaproofSteps, substitutions, fileContext, localContext) {
|
|
219
|
-
premises = reverse(premises); ///
|
|
220
|
-
|
|
221
|
-
metaproofSteps = reverse(metaproofSteps); ///
|
|
222
|
-
|
|
223
|
-
const premisesMatch = correlate(premises, metaproofSteps, (premise, metaproofStep) => {
|
|
224
|
-
const premiseMatches = metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localContext);
|
|
225
|
-
|
|
226
|
-
if (premiseMatches) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
return premisesMatch;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, localContext) {
|
|
235
|
-
const conclusionMatchesMetastatementNode = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext),
|
|
236
|
-
conclusionMatches = conclusionMatchesMetastatementNode; ///
|
|
237
|
-
|
|
238
|
-
return conclusionMatches;
|
|
239
|
-
}
|
package/src/ruleNames.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
4
|
-
export const META_ARGUMENT_RULE_NAME = "metaArgument";
|
|
5
4
|
export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
|
6
5
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
7
6
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
8
|
-
export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
|
|
@@ -5,6 +5,7 @@ import TermForVariableSubstitution from "./termForVariable";
|
|
|
5
5
|
import verifyStatementAgainstStatement from "../verify/statementAtainstStatement";
|
|
6
6
|
|
|
7
7
|
import { bracketedStatementChildNodeFromStatementNode } from "../utilities/match";
|
|
8
|
+
import { statementNodeFromStatementString, metavariableNodeFromMetavariableString } from "../utilities/node";
|
|
8
9
|
|
|
9
10
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
10
11
|
constructor(metavariableNode, statementNode, substitution) {
|
|
@@ -55,6 +56,19 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
55
56
|
return matchesMetavariableNode;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
60
|
+
const { metavariable, statement } = json,
|
|
61
|
+
metavariableString = metavariable, ///
|
|
62
|
+
statementString = statement, ///
|
|
63
|
+
lexer = fileContext.getLexer(),
|
|
64
|
+
parser = fileContext.getParser(),
|
|
65
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
66
|
+
metavariableNode = metavariableNodeFromMetavariableString(metavariableString, lexer, parser),
|
|
67
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode);
|
|
68
|
+
|
|
69
|
+
return statementForMetavariableSubstitution;
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
static fromMetavariableNodeAndStatementNode(metavariableNode, statementNode) {
|
|
59
73
|
let statementForMetavariableSubstitution;
|
|
60
74
|
|