occam-verify-cli 0.0.478 → 0.0.480
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/conclusion.js +113 -29
- package/lib/constants.js +5 -1
- package/lib/equality.js +10 -13
- package/lib/metaSubstitution.js +26 -24
- package/lib/premise.js +149 -38
- package/lib/rule.js +74 -16
- package/lib/ruleNames.js +13 -9
- package/lib/substitution.js +31 -29
- package/lib/type.js +22 -21
- package/lib/utilities/node.js +16 -15
- package/lib/variable.js +12 -19
- package/lib/verify/statement/qualified.js +6 -3
- package/lib/verify/statement.js +13 -12
- package/lib/verify/statementAsEquality.js +139 -0
- package/lib/verify/statementTypeAssertion.js +82 -0
- package/package.json +3 -3
- package/src/conclusion.js +176 -35
- package/src/constants.js +1 -0
- package/src/equality.js +14 -16
- package/src/metaSubstitution.js +33 -29
- package/src/premise.js +236 -50
- package/src/rule.js +96 -16
- package/src/ruleNames.js +3 -2
- package/src/substitution.js +37 -33
- package/src/type.js +26 -20
- package/src/utilities/node.js +13 -13
- package/src/variable.js +10 -16
- package/src/verify/statement/qualified.js +7 -2
- package/src/verify/statement.js +13 -15
- package/src/verify/statementAsEquality.js +146 -0
- package/src/verify/{assertion/type.js → statementTypeAssertion.js} +40 -31
- package/lib/verify/assertion/type.js +0 -78
- package/lib/verify/equality.js +0 -68
- package/src/verify/equality.js +0 -92
package/src/rule.js
CHANGED
|
@@ -40,6 +40,40 @@ export default class Rule {
|
|
|
40
40
|
return matchesLabelName;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
matchStatement(statementNode, proofContext) {
|
|
44
|
+
let statementNatches;
|
|
45
|
+
|
|
46
|
+
const premisesLength = this.premises.length;
|
|
47
|
+
|
|
48
|
+
if (premisesLength === 0) {
|
|
49
|
+
const substitutions = [],
|
|
50
|
+
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions);
|
|
51
|
+
|
|
52
|
+
statementNatches = conclusionMatches; ///
|
|
53
|
+
} else {
|
|
54
|
+
const proofSteps = proofContext.getProofSteps();
|
|
55
|
+
|
|
56
|
+
statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
|
|
57
|
+
let premisesMatchConclusion = false;
|
|
58
|
+
|
|
59
|
+
const substitutions = [],
|
|
60
|
+
premisesMatch = matchPremises(this.premises, proofSteps, substitutions);
|
|
61
|
+
|
|
62
|
+
if (premisesMatch) {
|
|
63
|
+
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions);
|
|
64
|
+
|
|
65
|
+
premisesMatchConclusion = conclusionMatches; ///
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (premisesMatchConclusion) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return statementNatches;
|
|
75
|
+
}
|
|
76
|
+
|
|
43
77
|
matchMetastatement(metastatementNode, metaproofContext) {
|
|
44
78
|
let metastatementNatches;
|
|
45
79
|
|
|
@@ -47,7 +81,7 @@ export default class Rule {
|
|
|
47
81
|
|
|
48
82
|
if (premisesLength === 0) {
|
|
49
83
|
const metaSubstitutions = [],
|
|
50
|
-
conclusionMatches =
|
|
84
|
+
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, metaSubstitutions);
|
|
51
85
|
|
|
52
86
|
metastatementNatches = conclusionMatches; ///
|
|
53
87
|
} else {
|
|
@@ -57,10 +91,10 @@ export default class Rule {
|
|
|
57
91
|
let premisesMatchConclusion = false;
|
|
58
92
|
|
|
59
93
|
const metaSubstitutions = [],
|
|
60
|
-
|
|
94
|
+
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, metaSubstitutions);
|
|
61
95
|
|
|
62
|
-
if (
|
|
63
|
-
const conclusionMatches =
|
|
96
|
+
if (premisesMatch) {
|
|
97
|
+
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, metaSubstitutions);
|
|
64
98
|
|
|
65
99
|
premisesMatchConclusion = conclusionMatches; ///
|
|
66
100
|
}
|
|
@@ -145,23 +179,69 @@ export default class Rule {
|
|
|
145
179
|
}
|
|
146
180
|
}
|
|
147
181
|
|
|
148
|
-
function matchPremise(premise,
|
|
182
|
+
function matchPremise(premise, proofSteps, substitutions) {
|
|
183
|
+
const proofStep = prune(proofSteps, (proofStep) => {
|
|
184
|
+
const subproofNode = proofStep.getSubproofNode(),
|
|
185
|
+
statementNode = proofStep.getStatementNode()
|
|
186
|
+
|
|
187
|
+
if (subproofNode !== null) {
|
|
188
|
+
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions);
|
|
189
|
+
|
|
190
|
+
if (!subProofNodeMatches) { ///
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (statementNode !== null) {
|
|
196
|
+
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions);
|
|
197
|
+
|
|
198
|
+
if (!statementNodeMatches) { ///
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}) || null;
|
|
203
|
+
|
|
204
|
+
const premiseMatches = (proofStep !== null);
|
|
205
|
+
|
|
206
|
+
return premiseMatches;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function matchPremises(premise, proofSteps, substitutions) {
|
|
210
|
+
const premisesMatch = premise.every((premise) => {
|
|
211
|
+
const premiseMatches = matchPremise(premise, proofSteps, substitutions);
|
|
212
|
+
|
|
213
|
+
if (premiseMatches) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return premisesMatch;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function matchConclusion(conclusion, statementNode, substitutions) {
|
|
222
|
+
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions),
|
|
223
|
+
conclusionMatches = statementNodeMatches; ///
|
|
224
|
+
|
|
225
|
+
return conclusionMatches;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function metaMatchPremise(premise, metaproofSteps, metaSubstitutions) {
|
|
149
229
|
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
150
230
|
const metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
151
231
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
152
232
|
|
|
153
233
|
if (metaSubproofNode !== null) {
|
|
154
|
-
const
|
|
234
|
+
const metaSubProofNodeMatches = premise.matchMetaSubproofNode(metaSubproofNode, metaSubstitutions);
|
|
155
235
|
|
|
156
|
-
if (!
|
|
236
|
+
if (!metaSubProofNodeMatches) { ///
|
|
157
237
|
return true;
|
|
158
238
|
}
|
|
159
239
|
}
|
|
160
240
|
|
|
161
241
|
if (metastatementNode !== null) {
|
|
162
|
-
const
|
|
242
|
+
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, metaSubstitutions);
|
|
163
243
|
|
|
164
|
-
if (!
|
|
244
|
+
if (!metastatementNodeMatches) { ///
|
|
165
245
|
return true;
|
|
166
246
|
}
|
|
167
247
|
}
|
|
@@ -172,21 +252,21 @@ function matchPremise(premise, metaproofSteps, metaSubstitutions) {
|
|
|
172
252
|
return premiseMatches;
|
|
173
253
|
}
|
|
174
254
|
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
const premiseMatches =
|
|
255
|
+
function metaMatchPremises(premise, metaproofSteps, metaSubstitutions) {
|
|
256
|
+
const premisesMatch = premise.every((premise) => {
|
|
257
|
+
const premiseMatches = metaMatchPremise(premise, metaproofSteps, metaSubstitutions);
|
|
178
258
|
|
|
179
259
|
if (premiseMatches) {
|
|
180
260
|
return true;
|
|
181
261
|
}
|
|
182
262
|
});
|
|
183
263
|
|
|
184
|
-
return
|
|
264
|
+
return premisesMatch;
|
|
185
265
|
}
|
|
186
266
|
|
|
187
|
-
function
|
|
188
|
-
const
|
|
189
|
-
conclusionMatches =
|
|
267
|
+
function metaMatchConclusion(conclusion, metastatementNode, metaSubstitutions) {
|
|
268
|
+
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, metaSubstitutions),
|
|
269
|
+
conclusionMatches = metastatementNodeMatches; ///
|
|
190
270
|
|
|
191
271
|
return conclusionMatches;
|
|
192
272
|
}
|
package/src/ruleNames.js
CHANGED
|
@@ -4,12 +4,13 @@ export const TERM_RULE_NAME = "term";
|
|
|
4
4
|
export const TYPE_RULE_NAME = "type";
|
|
5
5
|
export const LABEL_RULE_NAME = "label";
|
|
6
6
|
export const ARGUMENT_RULE_NAME = "argument";
|
|
7
|
+
export const SUBPROOF_RULE_NAME = "subproof";
|
|
8
|
+
export const STATEMENT_RULE_NAME = "statement";
|
|
7
9
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
8
10
|
export const METASTATEMENT_RULE_NAME = "metastatement";
|
|
9
11
|
export const META_SUBPROOF_RULE_NAME = "metaSubproof";
|
|
12
|
+
export const QUALIFIED_STATEMENT_RULE_NAME = "qualifiedStatement";
|
|
10
13
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
11
14
|
export const CONDITIONAL_INDICATIVE_RULE_NAME = "conditionalIndicative";
|
|
12
|
-
export const COMBINATOR_DECLARATION_RULE_NAME = "combinatorDeclaration";
|
|
13
|
-
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
14
15
|
export const QUALIFIED_METASTATEMENT_RULE_NAME = "qualifiedMetastatement";
|
|
15
16
|
export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
|
package/src/substitution.js
CHANGED
|
@@ -1,59 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { STATEMENT_RULE_NAME } from "./ruleNames";
|
|
4
|
+
import { matchNode, bracketedNonTerminalChildNodeFromChildNodes } from "./utilities/node";
|
|
4
5
|
|
|
5
6
|
export default class Substitution {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
7
|
+
constructor(metavariableName, statementNode) {
|
|
8
|
+
this.metavariableName = metavariableName;
|
|
9
|
+
this.statementNode = statementNode;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
return this.
|
|
12
|
+
getMetavariableName() {
|
|
13
|
+
return this.metavariableName;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
return this.
|
|
16
|
+
getStatementNode() {
|
|
17
|
+
return this.statementNode;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
let
|
|
20
|
+
matchStatementNode(statementNode) {
|
|
21
|
+
let matchesStatementNode;
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const nodeA = this.statementNode, ///
|
|
24
|
+
nodeB = statementNode,
|
|
25
|
+
nodeMatches = matchNode(nodeA, nodeB);
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
matchesStatementNode = nodeMatches; ///
|
|
27
28
|
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
if (!matchesStatementNode) {
|
|
30
|
+
const nonTerminalNode = statementNode, ///
|
|
31
|
+
childNodes = nonTerminalNode.getChildNodes(), ///
|
|
32
|
+
ruleName = STATEMENT_RULE_NAME;
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
const nonTerminalNode = bracketedChildNode, ///
|
|
34
|
-
childNodes = nonTerminalNode.getChildNodes(),
|
|
35
|
-
nodesB = childNodes, ///
|
|
36
|
-
nodesMatch = matchNodes(nodesA, nodesB);
|
|
34
|
+
statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
if (statementNode !== null) {
|
|
37
|
+
const nodeA = this.statementNode, ///
|
|
38
|
+
nodeB = statementNode,
|
|
39
|
+
nodeMatches = matchNode(nodeA, nodeB);
|
|
40
|
+
|
|
41
|
+
matchesStatementNode = nodeMatches; ///
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
return
|
|
45
|
+
return matchesStatementNode;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
static
|
|
46
|
-
|
|
48
|
+
static fromMetavariableNameAndStatementNode(metavariableName, statementNode) {
|
|
49
|
+
let substitution = new Substitution(metavariableName, statementNode);
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const nonTerminalNode = statementNode, ///
|
|
52
|
+
childNodes = nonTerminalNode.getChildNodes(),
|
|
53
|
+
ruleName = STATEMENT_RULE_NAME;
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
}
|
|
55
|
+
statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
if (statementNode !== null) {
|
|
58
|
+
substitution = new Substitution(metavariableName, statementNode);
|
|
59
|
+
}
|
|
56
60
|
|
|
57
|
-
return
|
|
61
|
+
return substitution;
|
|
58
62
|
}
|
|
59
63
|
}
|
package/src/type.js
CHANGED
|
@@ -17,39 +17,45 @@ export default class Type {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
isEqualTo(type) {
|
|
20
|
-
const
|
|
20
|
+
const equalTo = (this === type);
|
|
21
21
|
|
|
22
|
-
return
|
|
22
|
+
return equalTo;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
isSubTypeOf(type) {
|
|
26
|
-
let
|
|
26
|
+
let subTypeOf = false;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
28
|
+
let superType = this.superType;
|
|
29
|
+
|
|
30
|
+
while (superType !== null) {
|
|
31
|
+
if (superType === type) {
|
|
32
|
+
subTypeOf = true;
|
|
33
|
+
|
|
34
|
+
break;
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
superType = superType.getSuperType();
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
return
|
|
40
|
+
return subTypeOf;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
isSuperTypeOf(type) {
|
|
40
|
-
let
|
|
44
|
+
let superTypeOf = false;
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
let superType = type.getSuperType();
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
while (superType !== null) {
|
|
49
|
+
if (superType === this) {
|
|
50
|
+
superTypeOf = true;
|
|
51
|
+
|
|
52
|
+
break;
|
|
49
53
|
}
|
|
54
|
+
|
|
55
|
+
superType = superType.getSuperType();
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
return
|
|
58
|
+
return superTypeOf;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
isEqualToOrSubTypeOf(type) {
|
|
@@ -68,13 +74,13 @@ export default class Type {
|
|
|
68
74
|
return equalToTypeOrSuperTypeOf;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
match(type) {
|
|
72
78
|
const equalToType = this.isEqualTo(type),
|
|
73
79
|
subTypeOfType = this.isSubTypeOf(type),
|
|
74
80
|
superTypeOfType = this.isSuperTypeOf(type),
|
|
75
|
-
|
|
81
|
+
matches = (equalToType || subTypeOfType || superTypeOfType);
|
|
76
82
|
|
|
77
|
-
return
|
|
83
|
+
return matches;
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
matchName(name) {
|
package/src/utilities/node.js
CHANGED
|
@@ -61,10 +61,10 @@ export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB
|
|
|
61
61
|
if (!bracketedNodeMatches) {
|
|
62
62
|
const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
63
63
|
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
64
|
-
|
|
64
|
+
bracketedNonTerminalChildNodeA = bracketedNonTerminalChildNodeFromChildNodes(childNodesA);
|
|
65
65
|
|
|
66
|
-
if (
|
|
67
|
-
const nodeA =
|
|
66
|
+
if (bracketedNonTerminalChildNodeA !== null) {
|
|
67
|
+
const nodeA = bracketedNonTerminalChildNodeA, ///
|
|
68
68
|
nodeB = nonTerminalNodeB, ///
|
|
69
69
|
nodeMatches = matchNode(nodeA, nodeB);
|
|
70
70
|
|
|
@@ -75,10 +75,10 @@ export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB
|
|
|
75
75
|
if (!bracketedNodeMatches) {
|
|
76
76
|
const nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
77
77
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
78
|
-
|
|
78
|
+
bracketedNonTerminalChildNodeB = bracketedNonTerminalChildNodeFromChildNodes(childNodesB);
|
|
79
79
|
|
|
80
|
-
if (
|
|
81
|
-
const nodeB =
|
|
80
|
+
if (bracketedNonTerminalChildNodeB !== null) {
|
|
81
|
+
const nodeB = bracketedNonTerminalChildNodeB, ///
|
|
82
82
|
nodeA = nonTerminalNodeA, ///
|
|
83
83
|
nodeMatches = matchNode(nodeA, nodeB);
|
|
84
84
|
|
|
@@ -89,8 +89,8 @@ export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB
|
|
|
89
89
|
return bracketedNodeMatches;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export function
|
|
93
|
-
let
|
|
92
|
+
export function bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName = METASTATEMENT_RULE_NAME) {
|
|
93
|
+
let bracketedNonTerminalChildNode = null;
|
|
94
94
|
|
|
95
95
|
const childNodesLength = childNodes.length;
|
|
96
96
|
|
|
@@ -109,17 +109,17 @@ export function bracketedChildNodeFromChildNodes(childNodes) {
|
|
|
109
109
|
nonTerminalNodeRuleName = nonTerminalNode.getRuleName(),
|
|
110
110
|
firstTerminalNodeContent = firstTerminalNode.getContent(),
|
|
111
111
|
secondTerminalNodeContent = secondTerminalNode.getContent(),
|
|
112
|
+
nonTerminalNodeRuleNameRuleName = (nonTerminalNodeRuleName === ruleName),
|
|
112
113
|
firstTerminalNodeContentLeftBracket = (firstTerminalNodeContent === LEFT_BRACKET),
|
|
113
|
-
secondTerminalNodeContentRightBracket = (secondTerminalNodeContent === RIGHT_BRACKET)
|
|
114
|
-
nonTerminalNodeRuleNameMetastatementRuleName = (nonTerminalNodeRuleName === METASTATEMENT_RULE_NAME);
|
|
114
|
+
secondTerminalNodeContentRightBracket = (secondTerminalNodeContent === RIGHT_BRACKET);
|
|
115
115
|
|
|
116
|
-
if (
|
|
117
|
-
|
|
116
|
+
if (nonTerminalNodeRuleNameRuleName && firstTerminalNodeContentLeftBracket && secondTerminalNodeContentRightBracket) {
|
|
117
|
+
bracketedNonTerminalChildNode = nonTerminalNode; ///
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
return
|
|
122
|
+
return bracketedNonTerminalChildNode;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
function matchTerminalNode(terminalNodeA, terminalNodeB) {
|
package/src/variable.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export default class Variable {
|
|
4
|
-
constructor(type, name,
|
|
4
|
+
constructor(type, name, termNode) {
|
|
5
5
|
this.type = type;
|
|
6
6
|
this.name = name;
|
|
7
|
-
this.
|
|
7
|
+
this.termNode = termNode;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
getType() {
|
|
@@ -15,18 +15,12 @@ export default class Variable {
|
|
|
15
15
|
return this.name;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
return this.
|
|
18
|
+
getTermNode() {
|
|
19
|
+
return this.termNode;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return defined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
setValue(value) {
|
|
29
|
-
this.value = value;
|
|
22
|
+
setTermNode(termNode) {
|
|
23
|
+
this.termNode = termNode;
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
matchName(name) {
|
|
@@ -41,9 +35,9 @@ export default class Variable {
|
|
|
41
35
|
if (variable === this) {
|
|
42
36
|
equalTo = true;
|
|
43
37
|
} else {
|
|
44
|
-
const
|
|
38
|
+
const termNode = variable.getTermNode();
|
|
45
39
|
|
|
46
|
-
if (
|
|
40
|
+
if (termNode === this.termNode) {
|
|
47
41
|
equalTo = true;
|
|
48
42
|
}
|
|
49
43
|
}
|
|
@@ -66,8 +60,8 @@ export default class Variable {
|
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
static fromTypeAndName(type, name) {
|
|
69
|
-
const
|
|
70
|
-
variable = new Variable(type, name,
|
|
63
|
+
const termNode = null,
|
|
64
|
+
variable = new Variable(type, name, termNode);
|
|
71
65
|
|
|
72
66
|
return variable;
|
|
73
67
|
}
|
|
@@ -22,9 +22,14 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, proofCo
|
|
|
22
22
|
|
|
23
23
|
qualifiedStatementVerified = statementVerified; ///
|
|
24
24
|
} else {
|
|
25
|
-
const referenceName = referenceNameFromReferenceNode(referenceNode)
|
|
25
|
+
const referenceName = referenceNameFromReferenceNode(referenceNode),
|
|
26
|
+
rule = proofContext.findRuleByReferenceName(referenceName);
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
if (rule !== null) {
|
|
29
|
+
const ruleMatchesStatement = rule.matchStatement(statementNode, proofContext);
|
|
30
|
+
|
|
31
|
+
qualifiedStatementVerified = ruleMatchesStatement; ///
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
|
package/src/verify/statement.js
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import verifyStatementAsEquality from "../verify/statementAsEquality";
|
|
4
|
+
import verifyStatementTypeAssertion from "../verify/statementTypeAssertion";
|
|
5
5
|
|
|
6
|
-
import { nodeQuery } from "../utilities/query";
|
|
7
6
|
import { nodeAsString } from "../utilities/string";
|
|
8
7
|
|
|
9
|
-
const equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
10
|
-
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
|
|
11
|
-
|
|
12
8
|
export default function verifyStatement(statementNode, proofContext) {
|
|
13
9
|
let statementVerified = false;
|
|
14
10
|
|
|
15
11
|
proofContext.begin(statementNode);
|
|
16
12
|
|
|
17
|
-
const
|
|
18
|
-
statementString = nodeAsString(statementNode),
|
|
19
|
-
typeAssertionNode = typeAssertionNodeQuery(statementNode);
|
|
13
|
+
const statementString = nodeAsString(statementNode);
|
|
20
14
|
|
|
21
15
|
proofContext.debug(`Verifying the '${statementString}' statement...`);
|
|
22
16
|
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
17
|
+
if (!statementVerified) {
|
|
18
|
+
const equalityVerifiedAsEquality = verifyStatementAsEquality(statementNode, proofContext);
|
|
25
19
|
|
|
26
|
-
statementVerified =
|
|
20
|
+
statementVerified = equalityVerifiedAsEquality; ///
|
|
27
21
|
}
|
|
28
22
|
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
23
|
+
if (!statementVerified) {
|
|
24
|
+
const statementTypeAssertionVerified = verifyStatementTypeAssertion(statementNode, proofContext);
|
|
25
|
+
|
|
26
|
+
statementVerified = statementTypeAssertionVerified; ///
|
|
27
|
+
}
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
if (!statementVerified) {
|
|
30
|
+
statementVerified = true; ///
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
statementVerified ?
|