occam-verify-cli 0.0.697 → 0.0.700
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/assignment/equality.js +7 -5
- package/lib/assignment/metavariable.js +62 -0
- package/lib/assignment/variable.js +7 -5
- package/lib/constructor.js +3 -10
- package/lib/context/file.js +37 -97
- package/lib/context/local.js +28 -22
- package/lib/context/localMeta.js +21 -21
- package/lib/context/release.js +2 -4
- package/lib/equality.js +15 -7
- package/lib/metaType.js +10 -10
- package/lib/metavariable.js +27 -31
- package/lib/mixins/context.js +107 -0
- package/lib/ruleNames.js +9 -1
- package/lib/substitution/metastatementForMetavariable.js +17 -10
- package/lib/substitution/statementForMetavariable.js +17 -10
- package/lib/substitution/termForVariable.js +17 -11
- package/lib/type.js +23 -27
- package/lib/utilities/node.js +3 -73
- package/lib/utilities/query.js +2 -16
- package/lib/utilities/tokens.js +1 -8
- package/lib/variable.js +43 -36
- package/lib/verifier/node/metastatement.js +2 -3
- package/lib/verifier/node/statementAsCombinator.js +1 -1
- package/lib/verifier/node.js +2 -2
- package/lib/verifier/nodes/metastatementForMetavariable.js +5 -5
- package/lib/verifier/nodes/statementForMetavariable.js +5 -5
- package/lib/verifier/nodes/termForVariable.js +6 -6
- package/lib/verifier/nodes.js +2 -2
- package/lib/verify/axiom.js +3 -8
- package/lib/verify/conclusion.js +2 -2
- package/lib/verify/conjecture.js +4 -9
- package/lib/verify/derivation.js +3 -8
- package/lib/verify/equality.js +11 -11
- package/lib/verify/file.js +2 -2
- package/lib/verify/lemma.js +4 -9
- package/lib/verify/metavariable.js +8 -6
- package/lib/verify/premises.js +28 -0
- package/lib/verify/rule.js +3 -8
- package/lib/verify/ruleDerivation.js +6 -8
- package/lib/verify/standaloneType.js +32 -0
- package/lib/verify/statement/unqualified.js +2 -2
- package/lib/verify/supposition.js +4 -7
- package/lib/verify/suppositions.js +37 -0
- package/lib/verify/term.js +3 -4
- package/lib/verify/termAndStandaloneType.js +39 -0
- package/lib/verify/termAsVariableAndStandaloneType.js +39 -0
- package/lib/verify/theorem.js +4 -9
- package/lib/verify/type.js +2 -2
- package/lib/verify/typeAssertion.js +59 -89
- package/lib/verify/variable.js +12 -10
- package/package.json +1 -1
- package/src/assignment/equality.js +13 -4
- package/src/assignment/metavariable.js +30 -0
- package/src/assignment/variable.js +15 -4
- package/src/constructor.js +2 -7
- package/src/context/file.js +50 -41
- package/src/context/local.js +40 -27
- package/src/context/localMeta.js +26 -22
- package/src/context/release.js +6 -9
- package/src/equality.js +12 -5
- package/src/metaType.js +10 -10
- package/src/metavariable.js +24 -22
- package/src/mixins/{file.js → context.js} +20 -2
- package/src/ruleNames.js +2 -0
- package/src/substitution/metastatementForMetavariable.js +13 -7
- package/src/substitution/statementForMetavariable.js +13 -7
- package/src/substitution/termForVariable.js +13 -9
- package/src/type.js +27 -39
- package/src/utilities/node.js +3 -81
- package/src/utilities/query.js +1 -19
- package/src/utilities/tokens.js +0 -8
- package/src/variable.js +48 -30
- package/src/verifier/node/metastatement.js +1 -3
- package/src/verifier/node/statementAsCombinator.js +1 -1
- package/src/verifier/nodes/metastatementForMetavariable.js +5 -7
- package/src/verifier/nodes/statementForMetavariable.js +5 -7
- package/src/verifier/nodes/termForVariable.js +6 -8
- package/src/verify/axiom.js +2 -8
- package/src/verify/conclusion.js +1 -1
- package/src/verify/conjecture.js +3 -9
- package/src/verify/derivation.js +2 -8
- package/src/verify/equality.js +10 -10
- package/src/verify/file.js +1 -1
- package/src/verify/lemma.js +3 -9
- package/src/verify/metavariable.js +10 -9
- package/src/verify/premises.js +17 -0
- package/src/verify/rule.js +2 -8
- package/src/verify/ruleDerivation.js +5 -7
- package/src/verify/standaloneType.js +34 -0
- package/src/verify/statement/unqualified.js +1 -1
- package/src/verify/supposition.js +2 -7
- package/src/verify/suppositions.js +29 -0
- package/src/verify/term.js +3 -6
- package/src/verify/termAndStandaloneType.js +37 -0
- package/src/verify/termAsVariableAndStandaloneType.js +38 -0
- package/src/verify/theorem.js +3 -9
- package/src/verify/type.js +1 -1
- package/src/verify/typeAssertion.js +79 -110
- package/src/verify/variable.js +13 -13
- package/lib/mixins/file.js +0 -83
- package/lib/mixins/logging.js +0 -39
- package/src/mixins/logging.js +0 -24
package/src/type.js
CHANGED
|
@@ -58,29 +58,29 @@ export default class Type {
|
|
|
58
58
|
return superTypeOf;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
isComparableTo(type) {
|
|
62
62
|
const equalTo = this.isEqualTo(type),
|
|
63
63
|
subTypeOf = this.isSubTypeOf(type),
|
|
64
|
-
|
|
64
|
+
superTypeOf = this.isSuperTypeOf(type),
|
|
65
|
+
comparableTo = equalTo || subTypeOf || superTypeOf;
|
|
65
66
|
|
|
66
|
-
return
|
|
67
|
+
return comparableTo;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
isEqualToOrSubTypeOf(type) {
|
|
70
71
|
const equalTo = this.isEqualTo(type),
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
subTypeOf = this.isSubTypeOf(type),
|
|
73
|
+
equalToOrSubTypeOf = equalTo || subTypeOf;
|
|
73
74
|
|
|
74
|
-
return
|
|
75
|
+
return equalToOrSubTypeOf;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
isEqualToOrSuperTypeOf(type) {
|
|
78
79
|
const equalTo = this.isEqualTo(type),
|
|
79
|
-
subTypeOf = this.isSubTypeOf(type),
|
|
80
80
|
superTypeOf = this.isSuperTypeOf(type),
|
|
81
|
-
|
|
81
|
+
equalToOrSuperTypeOf = equalTo || superTypeOf;
|
|
82
82
|
|
|
83
|
-
return
|
|
83
|
+
return equalToOrSuperTypeOf;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
match(type) {
|
|
@@ -101,7 +101,7 @@ export default class Type {
|
|
|
101
101
|
return typeNameMatches;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
asString(tokens, noSuperType) {
|
|
104
|
+
asString(tokens, noSuperType = false) {
|
|
105
105
|
let string;
|
|
106
106
|
|
|
107
107
|
if (noSuperType) {
|
|
@@ -135,22 +135,6 @@ export default class Type {
|
|
|
135
135
|
return type;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
static fromJSONAndFileContext(json, fileContext) {
|
|
139
|
-
let type;
|
|
140
|
-
|
|
141
|
-
let { superType } = json;
|
|
142
|
-
|
|
143
|
-
const superTypeJSON = superType; ///
|
|
144
|
-
|
|
145
|
-
superType = superTypeFromSuperTypeJSONAndFileContext(superTypeJSON, fileContext);
|
|
146
|
-
|
|
147
|
-
const { name } = json;
|
|
148
|
-
|
|
149
|
-
type = new Type(name, superType);
|
|
150
|
-
|
|
151
|
-
return type;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
138
|
static fromTypeNameAndSuperType(typeName, superType) {
|
|
155
139
|
const name = typeName, ///
|
|
156
140
|
type = new Type(name, superType);
|
|
@@ -182,19 +166,23 @@ class ObjectType extends Type {
|
|
|
182
166
|
|
|
183
167
|
export const objectType = ObjectType.fromNothing();
|
|
184
168
|
|
|
185
|
-
function
|
|
186
|
-
let
|
|
169
|
+
export function typeFromJSONAndFileContext(json, fileContext) {
|
|
170
|
+
let type;
|
|
171
|
+
|
|
172
|
+
const { name } = json,
|
|
173
|
+
typeName = name; ///
|
|
187
174
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
type = fileContext.findTypeByTypeName(typeName);
|
|
175
|
+
type = fileContext.findTypeByTypeName(typeName);
|
|
176
|
+
|
|
177
|
+
if (type === null) {
|
|
178
|
+
let { superType } = json;
|
|
193
179
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
180
|
+
const superJSON = superType; ///
|
|
181
|
+
|
|
182
|
+
superType = typeFromJSONAndFileContext(superJSON, fileContext);
|
|
183
|
+
|
|
184
|
+
type = new Type(name, superType);
|
|
197
185
|
}
|
|
198
186
|
|
|
199
|
-
return
|
|
187
|
+
return type;
|
|
200
188
|
}
|
package/src/utilities/node.js
CHANGED
|
@@ -4,19 +4,14 @@ import { parsersUtilities } from "occam-custom-grammars";
|
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
6
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
VARIABLE_RULE_NAME,
|
|
10
|
-
META_TYPE_RULE_NAME,
|
|
11
|
-
METAVARIABLE_RULE_NAME,
|
|
7
|
+
import { LABEL_RULE_NAME,
|
|
8
|
+
VARIABLE_DECLARATION_RULE_NAME,
|
|
12
9
|
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
13
10
|
CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
14
11
|
UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
15
12
|
import { labelTokensFromLabelString,
|
|
16
|
-
constructorDeclarationTokensFromTermString,
|
|
17
13
|
variableDeclarationTokensFromVariableString,
|
|
18
14
|
unqualifiedStatementTokensFromStatementString,
|
|
19
|
-
metavariableDeclarationTokensFromMetavariableString,
|
|
20
15
|
unqualifiedMetastatementTokensFromMetastatementString } from "../utilities/tokens";
|
|
21
16
|
|
|
22
17
|
const { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
@@ -25,20 +20,10 @@ const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
|
25
20
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
26
21
|
|
|
27
22
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
28
|
-
typeNodeQuery = nodeQuery("/variableDeclaration/type!"),
|
|
29
23
|
variableNodeQuery = nodeQuery("/variableDeclaration/variable!"),
|
|
30
|
-
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType!"),
|
|
31
24
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
32
|
-
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable!"),
|
|
33
25
|
metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
|
|
34
26
|
|
|
35
|
-
export function termNodeFromTermString(termString, lexer, parser) {
|
|
36
|
-
const constructorDeclarationTokens = constructorDeclarationTokensFromTermString(termString, parser),
|
|
37
|
-
termNode = termNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser);
|
|
38
|
-
|
|
39
|
-
return termNode;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
27
|
export function labelNodeFromLabelString(labelString, lexer, parser) {
|
|
43
28
|
const labelTokens = labelTokensFromLabelString(labelString, lexer),
|
|
44
29
|
labelNode = labelNodeFromLabelTokens(labelTokens, parser);
|
|
@@ -46,13 +31,6 @@ export function labelNodeFromLabelString(labelString, lexer, parser) {
|
|
|
46
31
|
return labelNode;
|
|
47
32
|
}
|
|
48
33
|
|
|
49
|
-
export function typeNodeFromVariableString(variableString, lexer, parser) {
|
|
50
|
-
const variableDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
51
|
-
typeNode = typeNodeFromVariableVariableDeclarationTokens(variableDeclarationTokens, parser);
|
|
52
|
-
|
|
53
|
-
return typeNode;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
34
|
export function variableNodeFromVariableString(variableString, lexer, parser) {
|
|
57
35
|
const variableTDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
58
36
|
variableNode = variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser);
|
|
@@ -67,20 +45,6 @@ export function statementNodeFromStatementString(statementString, lexer, parser)
|
|
|
67
45
|
return statementNode;
|
|
68
46
|
}
|
|
69
47
|
|
|
70
|
-
export function metaTypeNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
71
|
-
const metavariableDeclarationTokens = metavariableDeclarationTokensFromMetavariableString(metavariableString, lexer),
|
|
72
|
-
metaTypeNode = metaTypeNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser);
|
|
73
|
-
|
|
74
|
-
return metaTypeNode;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function metavariableNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
78
|
-
const metavariableDeclarationTokens = metavariableDeclarationTokensFromMetavariableString(metavariableString, lexer),
|
|
79
|
-
metavariableNode = metavariableNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser);
|
|
80
|
-
|
|
81
|
-
return metavariableNode;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
48
|
export function metastatementNodeFromMetastatementString(metastatementString, lexer, parser) {
|
|
85
49
|
const unqualifiedMetastatementTokens = unqualifiedMetastatementTokensFromMetastatementString(metastatementString, lexer),
|
|
86
50
|
metastatementNode = metastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser);
|
|
@@ -102,27 +66,6 @@ export function statementNodeFromUnqualifiedStatementTokens(unqualifiedStatement
|
|
|
102
66
|
return statementNode;
|
|
103
67
|
}
|
|
104
68
|
|
|
105
|
-
export function typeNodeFromVariableVariableDeclarationTokens(variableDeclarationTokens, parser) {
|
|
106
|
-
const typeDeclarationNode = typeDeclarationNodeFromVariableDeclarationTokens(variableDeclarationTokens, parser),
|
|
107
|
-
typeNode = typeNodeQuery(typeDeclarationNode);
|
|
108
|
-
|
|
109
|
-
return typeNode;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function metaTypeNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
113
|
-
const metaTypeDeclarationNode = metaTypeDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser),
|
|
114
|
-
metaTypeNode = metaTypeNodeQuery(metaTypeDeclarationNode);
|
|
115
|
-
|
|
116
|
-
return metaTypeNode;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function metavariableNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
120
|
-
const metavariableDeclarationNode = metavariableDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser),
|
|
121
|
-
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode);
|
|
122
|
-
|
|
123
|
-
return metavariableNode;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
69
|
export function variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
127
70
|
const variableDeclarationNode = variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser),
|
|
128
71
|
variableNode = variableNodeQuery(variableDeclarationNode);
|
|
@@ -144,15 +87,8 @@ export function labelNodeFromLabelTokens(labelTokens, parser) {
|
|
|
144
87
|
return labelNode;
|
|
145
88
|
}
|
|
146
89
|
|
|
147
|
-
export function typeDeclarationNodeFromVariableDeclarationTokens(variableDeclarationTokens, parser) {
|
|
148
|
-
const ruleName = TYPE_RULE_NAME,
|
|
149
|
-
typeDeclarationNode = nodeFromTokensRuleNameAndParser(variableDeclarationTokens, ruleName, parser);
|
|
150
|
-
|
|
151
|
-
return typeDeclarationNode;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
90
|
export function variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
155
|
-
const ruleName =
|
|
91
|
+
const ruleName = VARIABLE_DECLARATION_RULE_NAME,
|
|
156
92
|
variableDeclarationNode = nodeFromTokensRuleNameAndParser(variableTDeclarationTokens, ruleName, parser);
|
|
157
93
|
|
|
158
94
|
return variableDeclarationNode;
|
|
@@ -165,13 +101,6 @@ export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifi
|
|
|
165
101
|
return unqualifiedStatementNode;
|
|
166
102
|
}
|
|
167
103
|
|
|
168
|
-
export function metaTypeDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
169
|
-
const ruleName = META_TYPE_RULE_NAME,
|
|
170
|
-
metaTypeDeclarationNode = nodeFromTokensRuleNameAndParser(metavariableDeclarationTokens, ruleName, parser);
|
|
171
|
-
|
|
172
|
-
return metaTypeDeclarationNode;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
104
|
export function constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
176
105
|
const ruleName = CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
177
106
|
constructorDeclarationNode = nodeFromTokensRuleNameAndParser(constructorDeclarationTokens, ruleName, parser);
|
|
@@ -179,13 +108,6 @@ export function constructorDeclarationNodeFromConstructorDeclarationTokens(const
|
|
|
179
108
|
return constructorDeclarationNode;
|
|
180
109
|
}
|
|
181
110
|
|
|
182
|
-
export function metavariableDeclarationNodeFromMetavariableDeclarationTokens(metavariableDeclarationTokens, parser) {
|
|
183
|
-
const ruleName = METAVARIABLE_RULE_NAME,
|
|
184
|
-
metavariableDeclarationNode = nodeFromTokensRuleNameAndParser(metavariableDeclarationTokens, ruleName, parser);
|
|
185
|
-
|
|
186
|
-
return metavariableDeclarationNode;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
111
|
export function unqualifiedMetastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser) {
|
|
190
112
|
const ruleName = UNQUALIFIED_METASTATEMENT_RULE_NAME,
|
|
191
113
|
unqualifiedMetastatementNode = nodeFromTokensRuleNameAndParser(unqualifiedMetastatementTokens, ruleName, parser);
|
package/src/utilities/query.js
CHANGED
|
@@ -5,9 +5,7 @@ import { Query } from "occam-dom";
|
|
|
5
5
|
const typeTerminalNodeQuery = nodeQuery("/type/@type"),
|
|
6
6
|
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type"),
|
|
7
7
|
labelNameTerminalNodeQuery = nodeQuery("/label/@name"),
|
|
8
|
-
|
|
9
|
-
referenceNameTerminalNodeQuery = nodeQuery("/reference/@name"),
|
|
10
|
-
metavariableNameTerminalNodeQuery = nodeQuery("/metavariable/@name");
|
|
8
|
+
referenceNameTerminalNodeQuery = nodeQuery("/reference/@name");
|
|
11
9
|
|
|
12
10
|
export function nodeQuery(expression) {
|
|
13
11
|
const query = Query.fromExpression(expression);
|
|
@@ -71,14 +69,6 @@ export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
|
|
|
71
69
|
return metaTypeName;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
export function variableNameFromVariableNode(variableNode) {
|
|
75
|
-
const variableNameTerminalNode = variableNameTerminalNodeQuery(variableNode),
|
|
76
|
-
variableNameTerminalNodeContent = variableNameTerminalNode.getContent(),
|
|
77
|
-
variableName = variableNameTerminalNodeContent; ///
|
|
78
|
-
|
|
79
|
-
return variableName;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
72
|
export function referenceNameFromReferenceNode(referenceNode) {
|
|
83
73
|
const referenceNameTerminalNode = referenceNameTerminalNodeQuery(referenceNode),
|
|
84
74
|
referenceNameTerminalNodeContent = referenceNameTerminalNode.getContent(),
|
|
@@ -86,11 +76,3 @@ export function referenceNameFromReferenceNode(referenceNode) {
|
|
|
86
76
|
|
|
87
77
|
return referenceName;
|
|
88
78
|
}
|
|
89
|
-
|
|
90
|
-
export function metavariableNameFromMetavariableNode(metavariableNode) {
|
|
91
|
-
const metavariableNameTerminalNode = metavariableNameTerminalNodeQuery(metavariableNode),
|
|
92
|
-
metavariableNameTerminalNodeContent = metavariableNameTerminalNode.getContent(),
|
|
93
|
-
metavariableName = metavariableNameTerminalNodeContent; ///
|
|
94
|
-
|
|
95
|
-
return metavariableName;
|
|
96
|
-
}
|
package/src/utilities/tokens.js
CHANGED
|
@@ -40,14 +40,6 @@ export function unqualifiedStatementTokensFromStatementString(statementString, l
|
|
|
40
40
|
return unqualifiedStatementTokens;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function metavariableDeclarationTokensFromMetavariableString(metavariableString, lexer) {
|
|
44
|
-
const metavariableDeclarationContent = `Metavariable ${metavariableString}
|
|
45
|
-
`,
|
|
46
|
-
metavariableDeclarationTokens = tokensFromContentAndLexer(metavariableDeclarationContent, lexer);
|
|
47
|
-
|
|
48
|
-
return metavariableDeclarationTokens;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
43
|
export function unqualifiedMetastatementTokensFromMetastatementString(metastatementString, lexer) {
|
|
52
44
|
const unqualifiedMetastatementContent = `${metastatementString}
|
|
53
45
|
`,
|
package/src/variable.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { nodeAsString } from "./utilities/string";
|
|
4
|
+
import { typeFromJSONAndFileContext } from "./type";
|
|
5
|
+
import { variableNodeFromVariableString } from "./utilities/node";
|
|
4
6
|
|
|
5
7
|
export default class Variable {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
8
|
+
constructor(node, type) {
|
|
9
|
+
this.node = node;
|
|
8
10
|
this.type = type;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
return this.
|
|
13
|
+
getNode() {
|
|
14
|
+
return this.node;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
getType() {
|
|
@@ -17,19 +19,19 @@ export default class Variable {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
match(variable) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
nameMatches = this.matchName(name),
|
|
22
|
+
const type = variable.getType(),
|
|
23
|
+
node = variable.getNode(),
|
|
23
24
|
typeMatches = this.matchType(type),
|
|
24
|
-
|
|
25
|
+
nodeMatches = this.matchNode(node),
|
|
26
|
+
matches = nodeMatches && typeMatches;
|
|
25
27
|
|
|
26
28
|
return matches;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
+
matchNode(node) {
|
|
32
|
+
const nodeMatches = this.node.match(node);
|
|
31
33
|
|
|
32
|
-
return
|
|
34
|
+
return nodeMatches;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
matchType(type) {
|
|
@@ -38,53 +40,69 @@ export default class Variable {
|
|
|
38
40
|
return typeMatches;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
+
matchNodeAndType(node, type) {
|
|
44
|
+
const nodeMatches = this.matchNode(node),
|
|
43
45
|
typeMatches = this.matchType(type),
|
|
44
|
-
|
|
46
|
+
nodeAndTypeMatch = nodeMatches && typeMatches;
|
|
45
47
|
|
|
46
|
-
return
|
|
48
|
+
return nodeAndTypeMatch;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
asString(tokens) {
|
|
50
|
-
const typeName = this.type.getName()
|
|
51
|
-
|
|
52
|
+
const typeName = this.type.getName();
|
|
53
|
+
|
|
54
|
+
let string = nodeAsString(this.node, tokens);
|
|
55
|
+
|
|
56
|
+
string = `${string}:${typeName}`; ///
|
|
52
57
|
|
|
53
58
|
return string;
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
toJSON(tokens) {
|
|
57
62
|
const typeJSON = this.type.toJSON(tokens),
|
|
58
|
-
|
|
63
|
+
string = nodeAsString(this.node, tokens),
|
|
64
|
+
node = string, //
|
|
59
65
|
type = typeJSON, ///
|
|
60
66
|
json = {
|
|
61
|
-
|
|
67
|
+
node,
|
|
62
68
|
type
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
return json;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
static
|
|
69
|
-
|
|
74
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
75
|
+
let { node } = json;
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
const lexer = fileContext.getLexer(),
|
|
78
|
+
parser = fileContext.getParser(),
|
|
79
|
+
variableString = node, ///
|
|
80
|
+
variableNode = variableNodeFromVariableString(variableString, lexer, parser);
|
|
73
81
|
|
|
74
|
-
|
|
75
|
-
const { name } = json;
|
|
82
|
+
node = variableNode; ///
|
|
76
83
|
|
|
77
84
|
let { type } = json;
|
|
78
85
|
|
|
79
86
|
json = type; ///
|
|
80
87
|
|
|
81
|
-
type =
|
|
88
|
+
type = typeFromJSONAndFileContext(json, fileContext);
|
|
82
89
|
|
|
83
|
-
const
|
|
90
|
+
const variable = new Variable(node, type);
|
|
84
91
|
|
|
85
|
-
|
|
92
|
+
return variable;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static fromVariableAndType(variable, type) {
|
|
96
|
+
const node = variable.getNode();
|
|
97
|
+
|
|
98
|
+
variable = new Variable(node, type); ///
|
|
99
|
+
|
|
100
|
+
return variable;
|
|
101
|
+
}
|
|
86
102
|
|
|
87
|
-
|
|
103
|
+
static fromVariableNodeAndType(variableNode, type) {
|
|
104
|
+
const node = variableNode, ///
|
|
105
|
+
variable = new Variable(node, type);
|
|
88
106
|
|
|
89
107
|
return variable;
|
|
90
108
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import NodeVerifier from "../../verifier/node";
|
|
4
4
|
|
|
5
5
|
import { METAVARIABLE_RULE_NAME } from "../../ruleNames";
|
|
6
|
-
import { metavariableNameFromMetavariableNode } from "../../utilities/query";
|
|
7
6
|
|
|
8
7
|
class MetastatementNodeVerifier extends NodeVerifier {
|
|
9
8
|
verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead) {
|
|
@@ -44,8 +43,7 @@ function verifyMetavariable(metavariableNode, localMetaContext, verifyAhead) {
|
|
|
44
43
|
|
|
45
44
|
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
46
45
|
|
|
47
|
-
const
|
|
48
|
-
metavariablePresent = localMetaContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
46
|
+
const metavariablePresent = localMetaContext.isMetavariablePresentByMetavariableNode(metavariableNode);
|
|
49
47
|
|
|
50
48
|
if (metavariablePresent) {
|
|
51
49
|
const verifiedAhead = verifyAhead();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import NodeVerifier from "../../verifier/node";
|
|
4
4
|
import verifyStatement from "../../verify/statement";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { verifyType, verifyStandaloneTerm } from "./../../verifier/node/termAsConstructor";
|
|
7
7
|
import { TYPE_RULE_NAME, TERM_RULE_NAME, STATEMENT_RULE_NAME } from "../../ruleNames";
|
|
8
8
|
|
|
9
9
|
class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
@@ -5,7 +5,6 @@ import MetastatementForMetavariableSubstitution from "../../substitution/metasta
|
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../../utilities/query";
|
|
7
7
|
import { METASTATEMENT_RULE_NAME } from "../../ruleNames";
|
|
8
|
-
import { metavariableNameFromMetavariableNode } from "../../utilities/query";
|
|
9
8
|
|
|
10
9
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
11
10
|
|
|
@@ -55,11 +54,10 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
55
54
|
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
56
55
|
let metavariableNodeVerified;
|
|
57
56
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const metavariableName = substitution.getMetavariableName();
|
|
57
|
+
const substitution = substitutions.find((substitution) => {
|
|
58
|
+
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNodeA);
|
|
61
59
|
|
|
62
|
-
if (
|
|
60
|
+
if (substitutionMatchesMetavariableNodeA) {
|
|
63
61
|
return true;
|
|
64
62
|
}
|
|
65
63
|
}) || null;
|
|
@@ -73,9 +71,9 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
73
71
|
const { createSubstitutions } = this.constructor;
|
|
74
72
|
|
|
75
73
|
if (createSubstitutions) {
|
|
76
|
-
const
|
|
74
|
+
const metavariableNode = metavariableNodeA, ///
|
|
77
75
|
metastatementNode = metastatementNodeB, ///
|
|
78
|
-
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.
|
|
76
|
+
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode),
|
|
79
77
|
substitution = metastatementForMetavariableSubstitution; ///
|
|
80
78
|
|
|
81
79
|
substitutions.push(substitution);
|
|
@@ -4,7 +4,6 @@ import NodesVerifier from "../../verifier/nodes";
|
|
|
4
4
|
import StatementForMetavariableSubstitution from "../../substitution/statementForMetavariable";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../../utilities/query";
|
|
7
|
-
import { metavariableNameFromMetavariableNode } from "../../utilities/query";
|
|
8
7
|
import { STATEMENT_RULE_NAME, METASTATEMENT_RULE_NAME, META_ARGUMENT_RULE_NAME } from "../../ruleNames";
|
|
9
8
|
|
|
10
9
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
|
|
@@ -71,11 +70,10 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
71
70
|
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, localContext) {
|
|
72
71
|
let metavariableNodeVerified;
|
|
73
72
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const metavariableName = substitution.getMetavariableName();
|
|
73
|
+
const substitution = substitutions.find((substitution) => {
|
|
74
|
+
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNodeA);
|
|
77
75
|
|
|
78
|
-
if (
|
|
76
|
+
if (substitutionMatchesMetavariableNodeA) {
|
|
79
77
|
return true;
|
|
80
78
|
}
|
|
81
79
|
}) || null;
|
|
@@ -89,9 +87,9 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
89
87
|
const { createSubstitutions } = this.constructor;
|
|
90
88
|
|
|
91
89
|
if (createSubstitutions) {
|
|
92
|
-
const
|
|
90
|
+
const metavariableNode = metavariableNodeA, ///
|
|
93
91
|
statementNode = statementNodeB, ///
|
|
94
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.
|
|
92
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode),
|
|
95
93
|
substitution = statementForMetavariableSubstitution; ///
|
|
96
94
|
|
|
97
95
|
substitutions.push(substitution);
|
|
@@ -7,7 +7,6 @@ import TermForVariableSubstitution from "../../substitution/termForVariable";
|
|
|
7
7
|
import { first } from "../../utilities/array";
|
|
8
8
|
import { nodeQuery } from "../../utilities/query";
|
|
9
9
|
import { TERM_RULE_NAME } from "../../ruleNames";
|
|
10
|
-
import { variableNameFromVariableNode } from "../../utilities/query";
|
|
11
10
|
|
|
12
11
|
const variableNodeQuery = nodeQuery('/term/variable!');
|
|
13
12
|
|
|
@@ -57,11 +56,10 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
57
56
|
verifyVariableNode(variableNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead) {
|
|
58
57
|
let variableVerified = false;
|
|
59
58
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const variableName = substitution.getVariableName();
|
|
59
|
+
const substitution = substitutions.find((substitution) => {
|
|
60
|
+
const substitutionMatchesVariableNodeA = substitution.matchVariableNode(variableNodeA);
|
|
63
61
|
|
|
64
|
-
if (
|
|
62
|
+
if (substitutionMatchesVariableNodeA) {
|
|
65
63
|
return true;
|
|
66
64
|
}
|
|
67
65
|
}) || null;
|
|
@@ -79,9 +77,9 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
79
77
|
const { createSubstitutions } = this.constructor;
|
|
80
78
|
|
|
81
79
|
if (createSubstitutions) {
|
|
82
|
-
const
|
|
80
|
+
const variableNode = variableNodeA, ///
|
|
83
81
|
localContext = localContextA, ///
|
|
84
|
-
variable = localContext.
|
|
82
|
+
variable = localContext.findVariableByVariableNode(variableNode);
|
|
85
83
|
|
|
86
84
|
if (variable !== null) {
|
|
87
85
|
const terms = [],
|
|
@@ -97,7 +95,7 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
97
95
|
variableTypeEqualToOrSuperTypeOfTermType = variableType.isEqualToOrSuperTypeOf(termType);
|
|
98
96
|
|
|
99
97
|
if (variableTypeEqualToOrSuperTypeOfTermType) {
|
|
100
|
-
const termForVariableSubstitution = TermForVariableSubstitution.
|
|
98
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromVariableNodeAndTermNode(variableNode, termNode),
|
|
101
99
|
substitution = termForVariableSubstitution; ///
|
|
102
100
|
|
|
103
101
|
substitutions.push(substitution);
|
package/src/verify/axiom.js
CHANGED
|
@@ -4,7 +4,7 @@ import Axiom from "../axiom";
|
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
6
|
import verifyConsequent from "../verify/consequent";
|
|
7
|
-
import
|
|
7
|
+
import verifySuppositions from "../verify/suppositions";
|
|
8
8
|
|
|
9
9
|
import { first } from "../utilities/array";
|
|
10
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
@@ -28,13 +28,7 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
28
28
|
if (labelsVerified) {
|
|
29
29
|
const suppositions = [],
|
|
30
30
|
suppositionNodes = suppositionsNodeQuery(axiomNode),
|
|
31
|
-
suppositionsVerified = suppositionNodes
|
|
32
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
33
|
-
|
|
34
|
-
if (suppositionVerified) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
31
|
+
suppositionsVerified = verifySuppositions(suppositionNodes, suppositions, localContext);
|
|
38
32
|
|
|
39
33
|
if (suppositionsVerified) {
|
|
40
34
|
const consequents = [],
|
package/src/verify/conclusion.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Conclusion from "../conclusion";
|
|
4
|
-
import verifyUnqualifiedMetastatement from "
|
|
4
|
+
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
|
package/src/verify/conjecture.js
CHANGED
|
@@ -4,8 +4,8 @@ import Conjecture from "../conjecture";
|
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
5
|
import LocalContext from "../context/local";
|
|
6
6
|
import verifyLabels from "../verify/labels";
|
|
7
|
-
import verifyConsequent from "
|
|
8
|
-
import
|
|
7
|
+
import verifyConsequent from "../verify/consequent";
|
|
8
|
+
import verifySuppositions from "../verify/suppositions";
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
@@ -30,13 +30,7 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
30
30
|
if (labelsVerified) {
|
|
31
31
|
const suppositions = [],
|
|
32
32
|
suppositionNodes = suppositionsNodeQuery(conjectureNode),
|
|
33
|
-
suppositionsVerified = suppositionNodes
|
|
34
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
35
|
-
|
|
36
|
-
if (suppositionVerified) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
33
|
+
suppositionsVerified = verifySuppositions(suppositionNodes, suppositions, localContext);
|
|
40
34
|
|
|
41
35
|
if (suppositionsVerified) {
|
|
42
36
|
const consequents = [],
|