occam-verify-cli 0.0.957 → 0.0.959
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/axiom.js +1 -7
- package/lib/combinator.js +1 -19
- package/lib/conclusion.js +1 -19
- package/lib/conjecture.js +1 -7
- package/lib/consequent.js +1 -19
- package/lib/constructor.js +1 -28
- package/lib/context/local.js +1 -14
- package/lib/label.js +1 -16
- package/lib/lemma.js +1 -7
- package/lib/metaLemma.js +1 -7
- package/lib/metaType.js +1 -10
- package/lib/metatheorem.js +1 -7
- package/lib/metavariable.js +1 -26
- package/lib/premise.js +1 -18
- package/lib/rule.js +1 -45
- package/lib/ruleNames.js +1 -9
- package/lib/substitution/statementForMetavariable.js +1 -9
- package/lib/substitutions.js +1 -27
- package/lib/supposition.js +1 -18
- package/lib/theorem.js +1 -7
- package/lib/topLevelAssertion.js +1 -46
- package/lib/type.js +2 -38
- package/lib/utilities/node.js +3 -42
- package/lib/utilities/tokens.js +1 -15
- package/lib/variable.js +1 -26
- package/lib/verify/assertion/type.js +21 -20
- package/package.json +1 -1
- package/src/axiom.js +0 -2
- package/src/combinator.js +0 -26
- package/src/conclusion.js +0 -24
- package/src/conjecture.js +0 -2
- package/src/consequent.js +0 -24
- package/src/constructor.js +0 -43
- package/src/context/local.js +0 -22
- package/src/label.js +0 -18
- package/src/lemma.js +0 -2
- package/src/metaLemma.js +0 -2
- package/src/metaType.js +0 -9
- package/src/metatheorem.js +0 -2
- package/src/metavariable.js +0 -38
- package/src/premise.js +0 -22
- package/src/rule.js +0 -65
- package/src/ruleNames.js +0 -2
- package/src/substitution/statementForMetavariable.js +0 -14
- package/src/substitutions.js +0 -27
- package/src/supposition.js +0 -22
- package/src/theorem.js +0 -2
- package/src/topLevelAssertion.js +0 -68
- package/src/type.js +0 -44
- package/src/utilities/node.js +2 -48
- package/src/utilities/tokens.js +0 -15
- package/src/variable.js +0 -36
- package/src/verify/assertion/type.js +26 -26
package/src/topLevelAssertion.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import Label from "./label";
|
|
4
|
-
import Consequent from "./consequent";
|
|
5
|
-
import Supposition from "./supposition";
|
|
6
3
|
import Substitutions from "./substitutions";
|
|
7
4
|
import unifyConsequentAgainstStatement from "./unify/consequentAgainstStatement";
|
|
8
5
|
import unifySuppositionsAgainstProofSteps from "./unify/suppositionsAgainstProofSteps";
|
|
@@ -69,70 +66,5 @@ export default class TopLevelAssertion {
|
|
|
69
66
|
return matchesMetavariableNode;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
toJSON(tokens) {
|
|
73
|
-
const labelsJSON = this.labels.map((label) => {
|
|
74
|
-
const labelJSON = label.toJSON(tokens);
|
|
75
|
-
|
|
76
|
-
return labelJSON;
|
|
77
|
-
}),
|
|
78
|
-
suppositionsJSON = this.suppositions.map((supposition) => {
|
|
79
|
-
const suppositionJSON = supposition.toJSON(tokens);
|
|
80
|
-
|
|
81
|
-
return suppositionJSON;
|
|
82
|
-
}),
|
|
83
|
-
consequentJSON = this.consequent.toJSON(tokens),
|
|
84
|
-
substitutionsJSON = this.substitutions.toJSON(tokens),
|
|
85
|
-
labels = labelsJSON, ///
|
|
86
|
-
suppositions = suppositionsJSON, ///
|
|
87
|
-
consequent = consequentJSON, ///
|
|
88
|
-
substitutions = substitutionsJSON, ///
|
|
89
|
-
json = {
|
|
90
|
-
labels,
|
|
91
|
-
suppositions,
|
|
92
|
-
consequent,
|
|
93
|
-
substitutions
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
return json;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static fromJSONAndFileContext(Class, json, fileContext) {
|
|
100
|
-
let { labels } = json;
|
|
101
|
-
|
|
102
|
-
const labelsJSON = labels; ///
|
|
103
|
-
|
|
104
|
-
labels = labelsJSON.map((labelJSON) => {
|
|
105
|
-
const json = labelJSON, ///
|
|
106
|
-
label = Label.fromJSONAndFileContext(json, fileContext);
|
|
107
|
-
|
|
108
|
-
return label;
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
let { suppositions, consequent, substitutions } = json;
|
|
112
|
-
|
|
113
|
-
const suppositionsJSON = suppositions; ///
|
|
114
|
-
|
|
115
|
-
suppositions = suppositionsJSON.map((suppositionJSON) => {
|
|
116
|
-
const json = suppositionJSON, ///
|
|
117
|
-
supposition = Supposition.fromJSONAndFileContext(json, fileContext);
|
|
118
|
-
|
|
119
|
-
return supposition;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const consequentJSON = consequent; ///
|
|
123
|
-
|
|
124
|
-
json = consequentJSON; ///
|
|
125
|
-
|
|
126
|
-
consequent = Consequent.fromJSONAndFileContext(json, fileContext);
|
|
127
|
-
|
|
128
|
-
const substitutionsJSON = substitutions; ///
|
|
129
|
-
|
|
130
|
-
json = substitutionsJSON; ///
|
|
131
|
-
|
|
132
|
-
substitutions = Substitutions.fromJSONAndFileContext(json, fileContext);
|
|
133
|
-
|
|
134
|
-
return new Class(labels, suppositions, consequent, substitutions, fileContext); ///
|
|
135
|
-
}
|
|
136
|
-
|
|
137
69
|
static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Class, labels, suppositions, consequent, substitutions, fileContext) { return new Class(labels, suppositions, consequent, substitutions, fileContext); }
|
|
138
70
|
}
|
package/src/type.js
CHANGED
|
@@ -125,18 +125,6 @@ export default class Type {
|
|
|
125
125
|
return string;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
toJSON(tokens) {
|
|
129
|
-
const superTypeJSON = this.superType.toJSON(tokens),
|
|
130
|
-
name = this.name,
|
|
131
|
-
superType = superTypeJSON, ///
|
|
132
|
-
json = {
|
|
133
|
-
name,
|
|
134
|
-
superType
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
return json;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
128
|
static fromTypeName(typeName) {
|
|
141
129
|
const name = typeName, ///
|
|
142
130
|
superType = objectType, ///
|
|
@@ -154,17 +142,6 @@ export default class Type {
|
|
|
154
142
|
}
|
|
155
143
|
|
|
156
144
|
class ObjectType extends Type {
|
|
157
|
-
toJSON(tokens) {
|
|
158
|
-
const name = this.name,
|
|
159
|
-
superType = null, ///
|
|
160
|
-
json = {
|
|
161
|
-
name,
|
|
162
|
-
superType
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
return json;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
145
|
static fromNothing() {
|
|
169
146
|
const name = OBJECT_TYPE_NAME,
|
|
170
147
|
superType = null,
|
|
@@ -175,24 +152,3 @@ class ObjectType extends Type {
|
|
|
175
152
|
}
|
|
176
153
|
|
|
177
154
|
export const objectType = ObjectType.fromNothing();
|
|
178
|
-
|
|
179
|
-
export function typeFromJSONAndFileContext(json, fileContext) {
|
|
180
|
-
let type;
|
|
181
|
-
|
|
182
|
-
const { name } = json,
|
|
183
|
-
typeName = name; ///
|
|
184
|
-
|
|
185
|
-
type = fileContext.findTypeByTypeName(typeName);
|
|
186
|
-
|
|
187
|
-
if (type === null) {
|
|
188
|
-
let { superType } = json;
|
|
189
|
-
|
|
190
|
-
const superJSON = superType; ///
|
|
191
|
-
|
|
192
|
-
superType = typeFromJSONAndFileContext(superJSON, fileContext);
|
|
193
|
-
|
|
194
|
-
type = new Type(name, superType);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return type;
|
|
198
|
-
}
|
package/src/utilities/node.js
CHANGED
|
@@ -4,13 +4,8 @@ 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
|
-
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
10
|
-
CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
11
|
-
import { metavariableTokensFromMetavariableString,
|
|
12
|
-
variableDeclarationTokensFromVariableString,
|
|
13
|
-
unqualifiedStatementTokensFromStatementString } from "../utilities/tokens";
|
|
7
|
+
import { unqualifiedStatementTokensFromStatementString } from "../utilities/tokens";
|
|
8
|
+
import { UNQUALIFIED_STATEMENT_RULE_NAME, CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
14
9
|
|
|
15
10
|
const { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
16
11
|
|
|
@@ -18,16 +13,8 @@ const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
|
18
13
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
19
14
|
|
|
20
15
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
21
|
-
variableNodeQuery = nodeQuery("/variableDeclaration/variable!"),
|
|
22
16
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!");
|
|
23
17
|
|
|
24
|
-
export function variableNodeFromVariableString(variableString, lexer, parser) {
|
|
25
|
-
const variableTDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
26
|
-
variableNode = variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser);
|
|
27
|
-
|
|
28
|
-
return variableNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
18
|
export function statementNodeFromStatementString(statementString, lexer, parser) {
|
|
32
19
|
const unqualifiedStatementTokens = unqualifiedStatementTokensFromStatementString(statementString, lexer),
|
|
33
20
|
statementNode = statementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser);
|
|
@@ -35,13 +22,6 @@ export function statementNodeFromStatementString(statementString, lexer, parser)
|
|
|
35
22
|
return statementNode;
|
|
36
23
|
}
|
|
37
24
|
|
|
38
|
-
export function metavariableNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
39
|
-
const metavariableTokens = metavariableTokensFromMetavariableString(metavariableString, lexer),
|
|
40
|
-
metavariableNode = metavariableNodeFromMetavariableTokens(metavariableTokens, parser);
|
|
41
|
-
|
|
42
|
-
return metavariableNode;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
25
|
export function termNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
46
26
|
let termNode = null;
|
|
47
27
|
|
|
@@ -66,32 +46,6 @@ export function statementNodeFromUnqualifiedStatementTokens(unqualifiedStatement
|
|
|
66
46
|
return statementNode;
|
|
67
47
|
}
|
|
68
48
|
|
|
69
|
-
export function variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
70
|
-
let variableNode = null;
|
|
71
|
-
|
|
72
|
-
const variableDeclarationNode = variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser);
|
|
73
|
-
|
|
74
|
-
if (variableDeclarationNode !== null) {
|
|
75
|
-
variableNode = variableNodeQuery(variableDeclarationNode);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return variableNode;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function metavariableNodeFromMetavariableTokens(metavariableTokens, parser) {
|
|
82
|
-
const ruleName = METAVARIABLE_RULE_NAME,
|
|
83
|
-
metavariableNode = nodeFromTokensRuleNameAndParser(metavariableTokens, ruleName, parser);
|
|
84
|
-
|
|
85
|
-
return metavariableNode;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
89
|
-
const ruleName = VARIABLE_DECLARATION_RULE_NAME,
|
|
90
|
-
variableDeclarationNode = nodeFromTokensRuleNameAndParser(variableTDeclarationTokens, ruleName, parser);
|
|
91
|
-
|
|
92
|
-
return variableDeclarationNode;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
49
|
export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser) {
|
|
96
50
|
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
97
51
|
unqualifiedStatementNode = nodeFromTokensRuleNameAndParser(unqualifiedStatementTokens, ruleName, parser);
|
package/src/utilities/tokens.js
CHANGED
|
@@ -9,13 +9,6 @@ const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities;
|
|
|
9
9
|
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
10
10
|
florenceLexer = florenceLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
11
11
|
|
|
12
|
-
export function metavariableTokensFromMetavariableString(metavariableString, lexer) {
|
|
13
|
-
const metavariableContent = `${metavariableString}`,
|
|
14
|
-
metavariableTokens = tokensFromContentAndLexer(metavariableContent, lexer);
|
|
15
|
-
|
|
16
|
-
return metavariableTokens;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
export function constructorDeclarationTokensFromTermString(termString, lexer) {
|
|
20
13
|
const constructorDeclarationContent = `Constructor ${termString}
|
|
21
14
|
`,
|
|
@@ -24,14 +17,6 @@ export function constructorDeclarationTokensFromTermString(termString, lexer) {
|
|
|
24
17
|
return constructorDeclarationTokens;
|
|
25
18
|
}
|
|
26
19
|
|
|
27
|
-
export function variableDeclarationTokensFromVariableString(variableString, lexer) {
|
|
28
|
-
const variableDeclarationContent = `Variable ${variableString}
|
|
29
|
-
`,
|
|
30
|
-
variableDeclarationTokens = tokensFromContentAndLexer(variableDeclarationContent, lexer);
|
|
31
|
-
|
|
32
|
-
return variableDeclarationTokens;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
20
|
export function unqualifiedStatementTokensFromStatementString(statementString, lexer) {
|
|
36
21
|
const unqualifiedStatementContent = `${statementString}
|
|
37
22
|
`,
|
package/src/variable.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { nodeAsString } from "./utilities/string";
|
|
4
|
-
import { typeFromJSONAndFileContext } from "./type";
|
|
5
|
-
import { variableNodeFromVariableString } from "./utilities/node";
|
|
6
4
|
|
|
7
5
|
export default class Variable {
|
|
8
6
|
constructor(node, type) {
|
|
@@ -58,40 +56,6 @@ export default class Variable {
|
|
|
58
56
|
return string;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
toJSON(tokens) {
|
|
62
|
-
const typeJSON = this.type.toJSON(tokens),
|
|
63
|
-
string = nodeAsString(this.node, tokens),
|
|
64
|
-
node = string, //
|
|
65
|
-
type = typeJSON, ///
|
|
66
|
-
json = {
|
|
67
|
-
node,
|
|
68
|
-
type
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return json;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static fromJSONAndFileContext(json, fileContext) {
|
|
75
|
-
let { node } = json;
|
|
76
|
-
|
|
77
|
-
const lexer = fileContext.getLexer(),
|
|
78
|
-
parser = fileContext.getParser(),
|
|
79
|
-
variableString = node, ///
|
|
80
|
-
variableNode = variableNodeFromVariableString(variableString, lexer, parser);
|
|
81
|
-
|
|
82
|
-
node = variableNode; ///
|
|
83
|
-
|
|
84
|
-
let { type } = json;
|
|
85
|
-
|
|
86
|
-
json = type; ///
|
|
87
|
-
|
|
88
|
-
type = typeFromJSONAndFileContext(json, fileContext);
|
|
89
|
-
|
|
90
|
-
const variable = new Variable(node, type);
|
|
91
|
-
|
|
92
|
-
return variable;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
59
|
static fromVariableAndType(variable, type) {
|
|
96
60
|
const node = variable.getNode();
|
|
97
61
|
|
|
@@ -115,43 +115,43 @@ function verifyStatedTypeAssertion(typeAssertionNode, assignments, derived, loca
|
|
|
115
115
|
const typeString = localContext.nodeAsString(typeNode);
|
|
116
116
|
|
|
117
117
|
localContext.debug(`The '${typeString}' type is not present.`, typeNode);
|
|
118
|
-
}
|
|
118
|
+
} else {
|
|
119
|
+
const terms = [],
|
|
120
|
+
termNode = termNodeQuery(typeAssertionNode),
|
|
121
|
+
termVerified = verifyTerm(termNode, terms, localContext, () => {
|
|
122
|
+
let verifiedAhead = false;
|
|
119
123
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
const firstTerm = first(terms),
|
|
125
|
+
term = firstTerm, ///
|
|
126
|
+
termType = term.getType(),
|
|
127
|
+
typeEqualToOrSubTypeOfTermType = type.isEqualToOrSubTypeOf(termType);
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
termType = term.getType(),
|
|
128
|
-
typeEqualToOrSubTypeOfTermType = type.isEqualToOrSubTypeOf(termType);
|
|
129
|
+
if (typeEqualToOrSubTypeOfTermType) {
|
|
130
|
+
const variableNode = variableNodeQuery(termNode);
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
if (variableNode === null) {
|
|
133
|
+
verifiedAhead = true;
|
|
134
|
+
} else {
|
|
135
|
+
let variable;
|
|
132
136
|
|
|
133
|
-
|
|
134
|
-
verifiedAhead = true;
|
|
135
|
-
} else {
|
|
136
|
-
let variable;
|
|
137
|
+
variable = localContext.findVariableByVariableNode(variableNode);
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
variable = Variable.fromVariableAndType(variable, type); ///
|
|
139
|
+
variable = Variable.fromVariableAndType(variable, type); ///
|
|
141
140
|
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
const variableAssignment = VariableAssignment.fromVariable(variable),
|
|
142
|
+
assignment = variableAssignment; ///
|
|
144
143
|
|
|
145
|
-
|
|
144
|
+
assignments.push(assignment);
|
|
146
145
|
|
|
147
|
-
|
|
146
|
+
verifiedAhead = true;
|
|
147
|
+
}
|
|
148
148
|
}
|
|
149
|
-
}
|
|
150
149
|
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
return verifiedAhead;
|
|
151
|
+
});
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
statedTypeAssertionVerified = termVerified; ///
|
|
154
|
+
}
|
|
155
155
|
|
|
156
156
|
if (statedTypeAssertionVerified) {
|
|
157
157
|
localContext.debug(`...verified the '${typeAssertionString}' stated type assertion.`, typeAssertionNode);
|