occam-verify-cli 0.0.1265 → 0.0.1267
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/dom/assertion/type.js +3 -3
- package/lib/dom/combinator.js +1 -15
- package/lib/dom/constructor.js +2 -17
- package/lib/dom/declaration/combinator.js +24 -4
- package/lib/dom/declaration/complexType.js +32 -3
- package/lib/dom/declaration/constructor.js +55 -5
- package/lib/dom/declaration/metavariable.js +55 -4
- package/lib/dom/declaration/type.js +30 -3
- package/lib/dom/declaration/variable.js +55 -6
- package/lib/dom/metavariable.js +2 -58
- package/lib/dom/property.js +10 -18
- package/lib/dom/statement.js +1 -15
- package/lib/dom/term.js +1 -43
- package/lib/dom/type.js +86 -31
- package/lib/dom/variable.js +2 -26
- package/lib/index.js +2 -1
- package/lib/utilities/customGrammar.js +2 -2
- package/lib/utilities/json.js +24 -1
- package/package.json +1 -1
- package/src/dom/assertion/type.js +2 -2
- package/src/dom/combinator.js +0 -18
- package/src/dom/constructor.js +1 -20
- package/src/dom/declaration/combinator.js +24 -3
- package/src/dom/declaration/complexType.js +43 -2
- package/src/dom/declaration/constructor.js +64 -4
- package/src/dom/declaration/metavariable.js +68 -3
- package/src/dom/declaration/type.js +38 -2
- package/src/dom/declaration/variable.js +69 -5
- package/src/dom/metavariable.js +1 -73
- package/src/dom/property.js +21 -22
- package/src/dom/statement.js +0 -18
- package/src/dom/term.js +0 -53
- package/src/dom/type.js +51 -37
- package/src/dom/variable.js +1 -33
- package/src/index.js +1 -0
- package/src/utilities/customGrammar.js +1 -2
- package/src/utilities/json.js +38 -10
package/src/dom/type.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
|
|
4
5
|
import { domAssigned } from "../dom";
|
|
5
6
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
6
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
7
|
-
import {
|
|
8
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
9
|
+
import { superTypeFromJSON, propertiesFromJSON, superTypeToSuperTypeJSON, propertiesToPropertiesJSON } from "../utilities/json";
|
|
8
10
|
|
|
9
|
-
const typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
|
|
10
|
-
|
|
11
|
+
const typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type[0]"),
|
|
12
|
+
propertyDeclarationNodesQuery = nodesQuery("/complexTypeDeclaration/propertyDeclaration"),
|
|
13
|
+
typeDeclarationSuperTypeNodeQuery = nodeQuery("/typeDeclaration|complexTypeDeclaration/type[1]");
|
|
11
14
|
|
|
12
15
|
class Type {
|
|
13
16
|
constructor(string, name, superType, properties) {
|
|
@@ -33,6 +36,22 @@ class Type {
|
|
|
33
36
|
return this.properties;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
setString(string) {
|
|
40
|
+
this.string = string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setName(name) {
|
|
44
|
+
this.name = name;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setSuperType(superType) {
|
|
48
|
+
this.superType = superType;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setProperties(properties) {
|
|
52
|
+
this.properties = properties;
|
|
53
|
+
}
|
|
54
|
+
|
|
36
55
|
isEqualTo(type) {
|
|
37
56
|
const equalTo = (this === type);
|
|
38
57
|
|
|
@@ -107,39 +126,6 @@ class Type {
|
|
|
107
126
|
return typeNodeMatches;
|
|
108
127
|
}
|
|
109
128
|
|
|
110
|
-
verifyWhenDeclared(fileContext) {
|
|
111
|
-
let verifiedWhenDeclared = false;
|
|
112
|
-
|
|
113
|
-
const typeString = this.string; ///
|
|
114
|
-
|
|
115
|
-
fileContext.trace(`Verifying the '${typeString}' type when declared...`);
|
|
116
|
-
|
|
117
|
-
const typePresent = fileContext.isTypePresentByTypeName(this.name);
|
|
118
|
-
|
|
119
|
-
if (typePresent) {
|
|
120
|
-
fileContext.debug(`The type '${typeString}' has already been declared.`);
|
|
121
|
-
} else {
|
|
122
|
-
const superTypeName = this.superType.getName(),
|
|
123
|
-
superType = fileContext.findTypeByTypeName(superTypeName);
|
|
124
|
-
|
|
125
|
-
if (superType === null) {
|
|
126
|
-
const superTypeString = this.superType.getString();
|
|
127
|
-
|
|
128
|
-
fileContext.debug(`The super-type '${superTypeString}' is not present.`);
|
|
129
|
-
} else {
|
|
130
|
-
this.superType = superType;
|
|
131
|
-
|
|
132
|
-
verifiedWhenDeclared = true;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (verifiedWhenDeclared) {
|
|
137
|
-
fileContext.debug(`...verified the '${typeString}' type when declared.`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return verifiedWhenDeclared;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
129
|
toJSON() {
|
|
144
130
|
const propertiesJSON = propertiesToPropertiesJSON(this.properties),
|
|
145
131
|
superTypeJSON = superTypeToSuperTypeJSON(this.superType),
|
|
@@ -240,6 +226,34 @@ function superTypeFromTypeDeclarationNode(typeDeclarationNode, fileContext) {
|
|
|
240
226
|
return superType;
|
|
241
227
|
}
|
|
242
228
|
|
|
229
|
+
function typeNameFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
230
|
+
const typeDeclarationTypeNode = typeDeclarationTypeNodeQuery(complexTypeDeclarationNode),
|
|
231
|
+
typeNode = typeDeclarationTypeNode, ///
|
|
232
|
+
typeName = typeNameFromTypeNode(typeNode);
|
|
233
|
+
|
|
234
|
+
return typeName;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function superTypeFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
238
|
+
const typeDeclarationSuperTypeNode = typeDeclarationSuperTypeNodeQuery(complexTypeDeclarationNode),
|
|
239
|
+
superTypeNode = typeDeclarationSuperTypeNode, ///
|
|
240
|
+
superType = Type.fromTypeNode(superTypeNode);
|
|
241
|
+
|
|
242
|
+
return superType;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
|
|
246
|
+
const propertyDeclarationNodes = propertyDeclarationNodesQuery(complexTypeDeclarationNode),
|
|
247
|
+
properties = propertyDeclarationNodes.map((propertyDeclarationNode) => {
|
|
248
|
+
const { Property } = dom,
|
|
249
|
+
property = Property.fromPropertyDeclarationNode(propertyDeclarationNode, fileContext);
|
|
250
|
+
|
|
251
|
+
return property;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return properties;
|
|
255
|
+
}
|
|
256
|
+
|
|
243
257
|
class ObjectType extends Type {
|
|
244
258
|
toJSON() {
|
|
245
259
|
const superType = null,
|
package/src/dom/variable.js
CHANGED
|
@@ -119,7 +119,7 @@ export default domAssigned(class Variable {
|
|
|
119
119
|
const type = fileContext.findTypeByTypeName(typeName);
|
|
120
120
|
|
|
121
121
|
if (type === null) {
|
|
122
|
-
fileContext.debug(`The '${typeName}' type is
|
|
122
|
+
fileContext.debug(`The '${typeName}' type is not present.`);
|
|
123
123
|
} else {
|
|
124
124
|
this.type = type; ///
|
|
125
125
|
|
|
@@ -134,38 +134,6 @@ export default domAssigned(class Variable {
|
|
|
134
134
|
return typeVerified;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
verifyWhenDeclared(fileContext) {
|
|
138
|
-
let verifiedWhenDeclared;
|
|
139
|
-
|
|
140
|
-
const variableString = this.string; ///
|
|
141
|
-
|
|
142
|
-
fileContext.trace(`Verifying the '${variableString}' variable when declared...`);
|
|
143
|
-
|
|
144
|
-
const variableName = this.name, ///
|
|
145
|
-
variablePresent = fileContext.isVariablePresentByVariableName(variableName);
|
|
146
|
-
|
|
147
|
-
if (variablePresent) {
|
|
148
|
-
fileContext.debug(`The '${variableName}' variable has already been declared.`);
|
|
149
|
-
} else {
|
|
150
|
-
const metavariableName = this.name, ///
|
|
151
|
-
metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
152
|
-
|
|
153
|
-
if (metavariablePresent) {
|
|
154
|
-
fileContext.debug(`A '${metavariableName}' variable has already been declared.`);
|
|
155
|
-
} else {
|
|
156
|
-
const typeVerified = this.verifyType(fileContext);
|
|
157
|
-
|
|
158
|
-
verifiedWhenDeclared = typeVerified; ///
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (verifiedWhenDeclared) {
|
|
163
|
-
fileContext.debug(`...verified the '${variableString}' variable when declared.`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return verifiedWhenDeclared;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
137
|
unifyTerm(term, substitutions, generalContext, specificContext) {
|
|
170
138
|
let termUnified = false;
|
|
171
139
|
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import Equality from "./dom/equality";
|
|
|
15
15
|
import MetaType from "./dom/metaType";
|
|
16
16
|
import Subproof from "./dom/subproof";
|
|
17
17
|
import Variable from "./dom/variable";
|
|
18
|
+
import Property from "./dom/property";
|
|
18
19
|
import Parameter from "./dom/parameter";
|
|
19
20
|
import ProofStep from "./dom/proofStep";
|
|
20
21
|
import Reference from "./dom/reference";
|
|
@@ -7,9 +7,8 @@ export function customGrammarFromNameAndEntries(name, entries) {
|
|
|
7
7
|
statementBNF = entries.getStatementBNF(),
|
|
8
8
|
typePattern = entries.getTypePattern(),
|
|
9
9
|
symbolPattern = entries.getSymbolPattern(),
|
|
10
|
-
propertyPattern = entries.getPropertyPattern(),
|
|
11
10
|
operatorPattern = entries.getOperatorPattern(),
|
|
12
|
-
customGrammar = CustomGrammar.
|
|
11
|
+
customGrammar = CustomGrammar.fromNameTermBNFStatementBNFTypePatternSymbolPatternAndOperatorPattern(name, termBNF, statementBNF, typePattern, symbolPattern, operatorPattern);
|
|
13
12
|
|
|
14
13
|
return customGrammar;
|
|
15
14
|
}
|
package/src/utilities/json.js
CHANGED
|
@@ -164,7 +164,7 @@ export function rulesFromJSON(json, fileContext) {
|
|
|
164
164
|
const json = ruleJSON, ///
|
|
165
165
|
rule = Rule.fromJSON(json, fileContext);
|
|
166
166
|
|
|
167
|
-
return
|
|
167
|
+
return rule;
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
return rules;
|
|
@@ -196,7 +196,7 @@ export function axiomsFromJSON(json, fileContext) {
|
|
|
196
196
|
const json = axiomJSON, ///
|
|
197
197
|
axiom = Axiom.fromJSON(json, fileContext);
|
|
198
198
|
|
|
199
|
-
return
|
|
199
|
+
return axiom;
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
return axioms;
|
|
@@ -228,7 +228,7 @@ export function theoremsFromJSON(json, fileContext) {
|
|
|
228
228
|
const json = theoremJSON, ///
|
|
229
229
|
theorem = Theorem.fromJSON(json, fileContext);
|
|
230
230
|
|
|
231
|
-
return
|
|
231
|
+
return theorem;
|
|
232
232
|
});
|
|
233
233
|
|
|
234
234
|
return theorems;
|
|
@@ -244,12 +244,28 @@ export function variablesFromJSON(json, fileContext) {
|
|
|
244
244
|
const json = variableJSON, ///
|
|
245
245
|
variable = Variable.fromJSON(json, fileContext);
|
|
246
246
|
|
|
247
|
-
return
|
|
247
|
+
return variable;
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
return variables;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
export function propertiesFromJSON(json, fileContext) {
|
|
254
|
+
let { properties } = json;
|
|
255
|
+
|
|
256
|
+
const { Property } = dom,
|
|
257
|
+
propertiesJSON = properties; ///
|
|
258
|
+
|
|
259
|
+
properties = propertiesJSON.map((propertyJSON) => {
|
|
260
|
+
const json = propertyJSON, ///
|
|
261
|
+
property = Property.fromJSON(json, fileContext);
|
|
262
|
+
|
|
263
|
+
return property;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
return properties;
|
|
267
|
+
}
|
|
268
|
+
|
|
253
269
|
export function parametersFromJSON(json, fileContext) {
|
|
254
270
|
let { parameters } = json;
|
|
255
271
|
|
|
@@ -260,7 +276,7 @@ export function parametersFromJSON(json, fileContext) {
|
|
|
260
276
|
const json = parameterJSON, ///
|
|
261
277
|
parameter = Parameter.fromJSON(json, fileContext);
|
|
262
278
|
|
|
263
|
-
return
|
|
279
|
+
return parameter;
|
|
264
280
|
});
|
|
265
281
|
|
|
266
282
|
return parameters;
|
|
@@ -276,7 +292,7 @@ export function conjecturesFromJSON(json, fileContext) {
|
|
|
276
292
|
const json = conjectureJSON, ///
|
|
277
293
|
conjecture = Conjecture.fromJSON(json, fileContext);
|
|
278
294
|
|
|
279
|
-
return
|
|
295
|
+
return conjecture;
|
|
280
296
|
});
|
|
281
297
|
|
|
282
298
|
return conjectures;
|
|
@@ -292,7 +308,7 @@ export function combinatorsFromJSON(json, fileContext) {
|
|
|
292
308
|
const json = combinatorJSON, ///
|
|
293
309
|
combinator = Combinator.fromJSON(json, fileContext);
|
|
294
310
|
|
|
295
|
-
return
|
|
311
|
+
return combinator;
|
|
296
312
|
});
|
|
297
313
|
|
|
298
314
|
return combinators;
|
|
@@ -308,7 +324,7 @@ export function constructorsFromJSON(json, fileContext) {
|
|
|
308
324
|
const json = constructorJSON, ///
|
|
309
325
|
constructor = Constructor.fromJSON(json, fileContext);
|
|
310
326
|
|
|
311
|
-
return
|
|
327
|
+
return constructor;
|
|
312
328
|
});
|
|
313
329
|
|
|
314
330
|
return constructors;
|
|
@@ -324,7 +340,7 @@ export function metatheoremsFromJSON(json, fileContext) {
|
|
|
324
340
|
const json = metatheoremJSON, ///
|
|
325
341
|
metatheorem = Metatheorem.fromJSON(json, fileContext);
|
|
326
342
|
|
|
327
|
-
return
|
|
343
|
+
return metatheorem;
|
|
328
344
|
});
|
|
329
345
|
|
|
330
346
|
return metatheorems;
|
|
@@ -372,7 +388,7 @@ export function metavariablesFromJSON(json, fileContext) {
|
|
|
372
388
|
const json = metavariableJSON, ///
|
|
373
389
|
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
374
390
|
|
|
375
|
-
return
|
|
391
|
+
return metavariable;
|
|
376
392
|
});
|
|
377
393
|
|
|
378
394
|
return metavariables;
|
|
@@ -547,6 +563,18 @@ export function parametersToParametersJSON(parameters) {
|
|
|
547
563
|
return parametersJSON;
|
|
548
564
|
}
|
|
549
565
|
|
|
566
|
+
export function propertiesToPropertiesJSON(properties) {
|
|
567
|
+
const propertiesJSON = properties.map((property) => {
|
|
568
|
+
const propertyJSON = property.toJSON();
|
|
569
|
+
|
|
570
|
+
property = propertyJSON; ///
|
|
571
|
+
|
|
572
|
+
return property;
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
return propertiesJSON;
|
|
576
|
+
}
|
|
577
|
+
|
|
550
578
|
export function conjecturesToConjecturesJSON(conjectures) {
|
|
551
579
|
const conjecturesJSON = conjectures.map((conjecture) => {
|
|
552
580
|
const conjectureJSON = conjecture.toJSON();
|