occam-verify-cli 1.0.890 → 1.0.895
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/context/file/nominal.js +9 -3
- package/lib/context/mnemic.js +68 -8
- package/lib/context/synoptic.js +33 -1
- package/lib/context.js +11 -1
- package/lib/element/assertion/property.js +7 -7
- package/lib/element/declaration/complexType.js +93 -134
- package/lib/element/declaration/property.js +81 -0
- package/lib/element/declaration/simpleType.js +8 -9
- package/lib/element/declaration/typePrefix.js +2 -27
- package/lib/element/metavariable.js +4 -4
- package/lib/element/property.js +81 -12
- package/lib/element/propertyRelation.js +37 -15
- package/lib/element/statement.js +2 -2
- package/lib/element/substitution/statement.js +2 -2
- package/lib/element/typePrefix.js +26 -1
- package/lib/preamble.js +2 -1
- package/lib/utilities/element.js +119 -18
- package/lib/utilities/json.js +10 -24
- package/lib/utilities/string.js +20 -2
- package/lib/utilities/synoptic.js +23 -1
- package/package.json +1 -1
- package/src/context/file/nominal.js +10 -2
- package/src/context/mnemic.js +123 -14
- package/src/context/synoptic.js +49 -1
- package/src/context.js +16 -0
- package/src/element/assertion/property.js +6 -6
- package/src/element/declaration/complexType.js +110 -168
- package/src/element/declaration/property.js +99 -0
- package/src/element/declaration/simpleType.js +8 -15
- package/src/element/declaration/typePrefix.js +1 -38
- package/src/element/metavariable.js +3 -3
- package/src/element/property.js +122 -13
- package/src/element/propertyRelation.js +54 -14
- package/src/element/statement.js +1 -1
- package/src/element/substitution/statement.js +1 -1
- package/src/element/typePrefix.js +36 -0
- package/src/preamble.js +1 -0
- package/src/utilities/element.js +139 -36
- package/src/utilities/json.js +16 -28
- package/src/utilities/string.js +37 -12
- package/src/utilities/synoptic.js +21 -1
package/src/element/property.js
CHANGED
|
@@ -6,22 +6,22 @@ import { define } from "../elements";
|
|
|
6
6
|
import { instantiate } from "../utilities/context";
|
|
7
7
|
import { instantiateProperty } from "../process/instantiate";
|
|
8
8
|
import { nameFromPropertyNode } from "../utilities/element";
|
|
9
|
-
import {
|
|
9
|
+
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
10
10
|
|
|
11
11
|
export default define(class Property extends Element {
|
|
12
|
-
constructor(context, string, node, lineIndex, name,
|
|
12
|
+
constructor(context, string, node, lineIndex, name, type) {
|
|
13
13
|
super(context, string, node, lineIndex);
|
|
14
14
|
|
|
15
15
|
this.name = name;
|
|
16
|
-
this.
|
|
16
|
+
this.type = type;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
getName() {
|
|
20
20
|
return this.name;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
return this.
|
|
23
|
+
getType() {
|
|
24
|
+
return this.type;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
getPropertyNode() {
|
|
@@ -31,27 +31,136 @@ export default define(class Property extends Element {
|
|
|
31
31
|
return properetyNode;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
setName(name) {
|
|
35
|
+
this.name = name;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setType(type) {
|
|
39
|
+
this.type = type;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
isEqualTo(property) {
|
|
43
|
+
const propertyNode = property.getNode(),
|
|
44
|
+
propertyNodeMatches = this.matchPropertyNode(propertyNode),
|
|
45
|
+
equalTo = propertyNodeMatches; ///
|
|
46
|
+
|
|
47
|
+
return equalTo;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
matchPropertyNode(propertyNode) {
|
|
51
|
+
const node = propertyNode, ///
|
|
52
|
+
nodeMatches = this.matchNode(node),
|
|
53
|
+
propertyNodeMatches = nodeMatches; ///
|
|
54
|
+
|
|
55
|
+
return propertyNodeMatches;
|
|
56
|
+
}
|
|
57
|
+
|
|
34
58
|
comparePropertyName(propertyName) {
|
|
35
59
|
const comparesToPropertyName = (this.name === propertyName);
|
|
36
60
|
|
|
37
61
|
return comparesToPropertyName;
|
|
38
62
|
}
|
|
39
63
|
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
verify(properties, context) {
|
|
65
|
+
let verifies = false;
|
|
66
|
+
|
|
67
|
+
const propertyString = this.getString(); ///
|
|
68
|
+
|
|
69
|
+
context.trace(`Verifying the '${propertyString}' property...`);
|
|
70
|
+
|
|
71
|
+
const naemVerifies = this.verifyName(properties, context);
|
|
72
|
+
|
|
73
|
+
if (naemVerifies) {
|
|
74
|
+
verifies = true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (verifies) {
|
|
78
|
+
context.debug(`...verified the '${propertyString}' property.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return verifies;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
verifyName(properties, context) {
|
|
85
|
+
let naemVerifies = false;
|
|
86
|
+
|
|
87
|
+
const propertyString = this.getString();
|
|
88
|
+
|
|
89
|
+
context.trace(`Verifying the '${propertyString}' property's name...`);
|
|
90
|
+
|
|
91
|
+
const propertyName = this.name, ///
|
|
92
|
+
count = properties.reduce((count, property) => {
|
|
93
|
+
if (property !== this) {
|
|
94
|
+
const propertyComparesToPropertyName = property.comparePropertyName(propertyName);
|
|
95
|
+
|
|
96
|
+
if (propertyComparesToPropertyName) {
|
|
97
|
+
count++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return count;
|
|
102
|
+
}, 0);
|
|
103
|
+
|
|
104
|
+
if (count === 0) {
|
|
105
|
+
naemVerifies = true;
|
|
106
|
+
} else {
|
|
107
|
+
context.debug(`The '${propertyString}' property appears more than once.`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (naemVerifies) {
|
|
111
|
+
context.debug(`...verified the '${propertyString}' property's name.`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return naemVerifies;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
findValidProperty(context) {
|
|
118
|
+
const propertyNode = this.getPropertyNode(),
|
|
119
|
+
property = context.findPropertyByPropertyNode(propertyNode),
|
|
120
|
+
validProperty = property; ///
|
|
121
|
+
|
|
122
|
+
return validProperty;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
validate(context) {
|
|
126
|
+
let property = null;
|
|
127
|
+
|
|
128
|
+
const propertyString = this.getString(); ///
|
|
129
|
+
|
|
130
|
+
context.trace(`Validating the '${propertyString}' property...`);
|
|
131
|
+
|
|
132
|
+
const validProperty = this.findValidProperty(context);
|
|
133
|
+
|
|
134
|
+
if (validProperty) {
|
|
135
|
+
property = validProperty; ///
|
|
136
|
+
|
|
137
|
+
context.debug(`...the '${propertyString}' property is already valid.`);
|
|
138
|
+
} else {
|
|
139
|
+
let validates = false;
|
|
140
|
+
|
|
141
|
+
debugger
|
|
142
|
+
|
|
143
|
+
if (validates) {
|
|
144
|
+
const property = this; ///
|
|
145
|
+
|
|
146
|
+
context.addProperty(property);
|
|
147
|
+
|
|
148
|
+
context.debug(`...validated the '${propertyString}' property.`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
42
151
|
|
|
43
|
-
return
|
|
152
|
+
return property;
|
|
44
153
|
}
|
|
45
154
|
|
|
46
155
|
toJSON() {
|
|
47
|
-
const
|
|
48
|
-
nominalTypeName = nominalTypeNameJSON, ///
|
|
156
|
+
const typeJSON = typeToTypeJSON(this.type),
|
|
49
157
|
string = this.getString(),
|
|
50
158
|
lineIndex = this.getLineIndex(),
|
|
159
|
+
type = typeJSON, ///
|
|
51
160
|
json = {
|
|
52
161
|
string,
|
|
53
162
|
lineIndex,
|
|
54
|
-
|
|
163
|
+
type
|
|
55
164
|
};
|
|
56
165
|
|
|
57
166
|
return json;
|
|
@@ -65,11 +174,11 @@ export default define(class Property extends Element {
|
|
|
65
174
|
propertyNode = instantiateProperty(string, context),
|
|
66
175
|
node = propertyNode, ///
|
|
67
176
|
name = nameFromPropertyNode(propertyNode, context),
|
|
68
|
-
|
|
177
|
+
type = typeFromJSON(json, context);
|
|
69
178
|
|
|
70
179
|
context = null;
|
|
71
180
|
|
|
72
|
-
const property = new Property(context, string, node, lineIndex, name,
|
|
181
|
+
const property = new Property(context, string, node, lineIndex, name, type);
|
|
73
182
|
|
|
74
183
|
return property;
|
|
75
184
|
}, context);
|
|
@@ -30,34 +30,74 @@ export default define(class PropertyRelation extends Element {
|
|
|
30
30
|
return propertyRelationNode;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
isEqualTo(propertyRelation) {
|
|
34
|
+
const propertyRelationNode = propertyRelation.getNode(),
|
|
35
|
+
propertyRelationNodeMatches = this.matchPropertyRelationNode(propertyRelationNode),
|
|
36
|
+
equalTo = propertyRelationNodeMatches; ///
|
|
37
|
+
|
|
38
|
+
return equalTo;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
matchPropertyRelationNode(propertyRelationNode) {
|
|
42
|
+
const node = propertyRelationNode, ///
|
|
43
|
+
nodeMatches = this.matchNode(node),
|
|
44
|
+
propertyRelationNodeMatches = nodeMatches; ///
|
|
45
|
+
|
|
46
|
+
return propertyRelationNodeMatches;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
findValidPropertyRelation(context) {
|
|
50
|
+
const propertyRelationNode = this.getPropertyRelationNode(),
|
|
51
|
+
propertyRelation = context.findPropertyRelationByPropertyRelationNode(propertyRelationNode),
|
|
52
|
+
validPropertyRelation = propertyRelation; ///
|
|
53
|
+
|
|
54
|
+
return validPropertyRelation;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
validate(context) {
|
|
58
|
+
let propertyRelation = null;
|
|
35
59
|
|
|
36
60
|
const propertyRelationString = this.getString(); ///
|
|
37
61
|
|
|
38
|
-
context.trace(`
|
|
62
|
+
context.trace(`Validating the '${propertyRelationString}' property relation...`);
|
|
39
63
|
|
|
40
|
-
const
|
|
64
|
+
const validPropertyRelation = this.findValidPropertyRelation(context);
|
|
41
65
|
|
|
42
|
-
if (
|
|
43
|
-
|
|
66
|
+
if (validPropertyRelation) {
|
|
67
|
+
propertyRelation = validPropertyRelation; ///
|
|
44
68
|
|
|
45
|
-
|
|
46
|
-
}
|
|
69
|
+
context.debug(`...the '${propertyRelationString}' property relation is already valid.`);
|
|
70
|
+
} else {
|
|
71
|
+
let validates = false;
|
|
72
|
+
|
|
73
|
+
const termValidates = this.validateTerm(context);
|
|
74
|
+
|
|
75
|
+
if (termValidates) {
|
|
76
|
+
const propertyVerifies = this.verifyProperty(context);
|
|
77
|
+
|
|
78
|
+
validates = propertyVerifies;
|
|
79
|
+
}
|
|
47
80
|
|
|
48
|
-
|
|
49
|
-
|
|
81
|
+
if (validates) {
|
|
82
|
+
const propertyRelation = this; ///
|
|
83
|
+
|
|
84
|
+
this.assign(context);
|
|
85
|
+
|
|
86
|
+
context.addPropertyRelation(propertyRelation);
|
|
87
|
+
|
|
88
|
+
context.debug(`...validated the '${propertyRelationString}' property relation.`);
|
|
89
|
+
}
|
|
50
90
|
}
|
|
51
91
|
|
|
52
|
-
return
|
|
92
|
+
return propertyRelation;
|
|
53
93
|
}
|
|
54
94
|
|
|
55
95
|
validateTerm(context) {
|
|
56
96
|
let termValidates = false;
|
|
57
97
|
|
|
58
|
-
const
|
|
98
|
+
const propertyRelationString = this.getString(); ///
|
|
59
99
|
|
|
60
|
-
context.trace(`Validating the '${
|
|
100
|
+
context.trace(`Validating the '${propertyRelationString}' property relation's term...`);
|
|
61
101
|
|
|
62
102
|
const term = this.term.validate(context, (term) => {
|
|
63
103
|
const validatesForwards = true;
|
|
@@ -72,7 +112,7 @@ export default define(class PropertyRelation extends Element {
|
|
|
72
112
|
}
|
|
73
113
|
|
|
74
114
|
if (termValidates) {
|
|
75
|
-
context.debug(`...validated the '${
|
|
115
|
+
context.debug(`...validated the '${propertyRelationString}' property relation's term.`);
|
|
76
116
|
}
|
|
77
117
|
|
|
78
118
|
return termValidates;
|
package/src/element/statement.js
CHANGED
|
@@ -229,7 +229,7 @@ export default define(class Statement extends Element {
|
|
|
229
229
|
if (subproofAssertionNode !== null) {
|
|
230
230
|
const context = generalContext, ///
|
|
231
231
|
subproofString = subproof.getString(),
|
|
232
|
-
statementString = this.getString();
|
|
232
|
+
statementString = this.getString(); ///
|
|
233
233
|
|
|
234
234
|
context.trace(`Unifying the '${subproofString}' subproof with the '${statementString}' statement...`);
|
|
235
235
|
|
|
@@ -141,7 +141,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
141
141
|
|
|
142
142
|
if (substitution !== null) {
|
|
143
143
|
const context = generalContext, ///
|
|
144
|
-
statementSubstitutionString = this.getString();
|
|
144
|
+
statementSubstitutionString = this.getString(); ///
|
|
145
145
|
|
|
146
146
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's substitution...`);
|
|
147
147
|
|
|
@@ -31,6 +31,42 @@ export default define(class TypePrefix extends Element {
|
|
|
31
31
|
return comparesToTypePrefixName;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
verify(context) {
|
|
35
|
+
let verifies = false;
|
|
36
|
+
|
|
37
|
+
const typePrefixString = this.getString(); ///
|
|
38
|
+
|
|
39
|
+
context.trace(`Verifying the '${typePrefixString}' type prefix...`);
|
|
40
|
+
|
|
41
|
+
const typePrefix = context.getTypePrefix();
|
|
42
|
+
|
|
43
|
+
if (typePrefix === null) {
|
|
44
|
+
const typePrefixName = this.name, ///
|
|
45
|
+
typePrefixPresent = context.isTypePrefixPresentByTypePrefixName(typePrefixName);
|
|
46
|
+
|
|
47
|
+
if (!typePrefixPresent) {
|
|
48
|
+
const nominalTypeName = typePrefixName, ///
|
|
49
|
+
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
50
|
+
|
|
51
|
+
if (!typePresent) {
|
|
52
|
+
verifies = true;
|
|
53
|
+
} else {
|
|
54
|
+
context.debug(`The '${typePrefixString}' type is already present.`);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
context.debug(`The '${typePrefixString}' type prefix is already present.`);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
context.trace(`The package already has a '${typePrefixString}' type prefix.`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (verifies) {
|
|
64
|
+
context.debug(`...verified the '${typePrefixString}' type prefix.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return verifies;
|
|
68
|
+
}
|
|
69
|
+
|
|
34
70
|
static name = "TypePrefix";
|
|
35
71
|
|
|
36
72
|
toJSON() {
|
package/src/preamble.js
CHANGED
|
@@ -50,6 +50,7 @@ import ProcedureReference from "./element/procedureReference";
|
|
|
50
50
|
import ContainedAssertion from "./element/assertion/contained";
|
|
51
51
|
import SatisfiesAssertion from "./element/assertion/satisfies";
|
|
52
52
|
import MetaLevelAssumption from "./element/assumption/metaLevel";
|
|
53
|
+
import PropertyDeclaration from "./element/declaration/property";
|
|
53
54
|
import VariableDeclaration from "./element/declaration/variable";
|
|
54
55
|
import BracketedCombinator from "./element/combinator/bracketed";
|
|
55
56
|
import BracketedConstructor from "./element/constructor/bracketed";
|