occam-verify-cli 1.0.896 → 1.0.899

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/src/context.js CHANGED
@@ -240,6 +240,13 @@ export default class Context extends ContextBase {
240
240
  return equality;
241
241
  }
242
242
 
243
+ findPropertyByPropertyNode(propertyNode) {
244
+ const context = this.getContext(),
245
+ property = context.findPropertyByPropertyNode(propertyNode);
246
+
247
+ return property;
248
+ }
249
+
243
250
  findJudgementByJudgementNode(judgementNode) {
244
251
  const context = this.getContext(),
245
252
  judgement = context.findJudgementByJudgementNode(judgementNode);
@@ -303,6 +310,13 @@ export default class Context extends ContextBase {
303
310
  return substitution;
304
311
  }
305
312
 
313
+ findPropertyRelationByPropertyRelationNode(propertyRelationNode) {
314
+ const context = this.getContext(),
315
+ propertyRelation = context.findPropertyRelationByPropertyRelationNode(propertyRelationNode);
316
+
317
+ return propertyRelation;
318
+ }
319
+
306
320
  findDeclaredJudgementsByMetavariableNode(metavariableNode) {
307
321
  const context = this.getContext(),
308
322
  declaredJudgements = context.findDeclaredJudgementsByMetavariableNode(metavariableNode);
@@ -586,6 +600,12 @@ export default class Context extends ContextBase {
586
600
  context.addEquality(equality);
587
601
  }
588
602
 
603
+ addProperty(property) {
604
+ const context = this.getContext();
605
+
606
+ context.addProperty(property);
607
+ }
608
+
589
609
  addJudgement(judgement) {
590
610
  const context = this.getContext();
591
611
 
@@ -634,6 +654,12 @@ export default class Context extends ContextBase {
634
654
  context.addSubstitution(substitution);
635
655
  }
636
656
 
657
+ addPropertyRelation(propertyRelation) {
658
+ const context = this.getContext();
659
+
660
+ context.addPropertyRelation(propertyRelation);
661
+ }
662
+
637
663
  addDeclaredVariable(declaredVariable) {
638
664
  const context = this.getContext();
639
665
 
@@ -31,6 +31,8 @@ export default define(class PropertyAssertion extends Assertion {
31
31
  return propertyAssertionNode;
32
32
  }
33
33
 
34
+ getType() { return this.propertyRelation.getType(); }
35
+
34
36
  compareTermAndPropertyRelation(term, propertyRelation, context) {
35
37
  let comparesToTermAndPropertyRelation = false;
36
38
 
@@ -148,7 +150,13 @@ export default define(class PropertyAssertion extends Assertion {
148
150
  const propertyRelation = this.propertyRelation.validate(context);
149
151
 
150
152
  if (propertyRelation !== null) {
151
- propertyRelationValidates = true;
153
+ const type = this.getType(),
154
+ termType = this.term.getType(),
155
+ termTypeEqualToOrSuperTypeOfType = termType.isEqualToOrSuperTypeOf(type);
156
+
157
+ if (termTypeEqualToOrSuperTypeOfType) {
158
+ propertyRelationValidates = true;
159
+ }
152
160
  }
153
161
 
154
162
  if (propertyRelationValidates) {
@@ -105,7 +105,8 @@ export default define(class ComplexTypeDeclaration extends Declaration {
105
105
  context.trace(`Verifying the '${complexTypeDeclarationString}' complex type declaration's '${typeString}' type...`);
106
106
 
107
107
  const typeName = this.type.getName(),
108
- typePresent = context.isTypePresentByTypeName(typeName);
108
+ includeRelease = false,
109
+ typePresent = context.isTypePresentByTypeName(typeName, includeRelease);
109
110
 
110
111
  if (!typePresent) {
111
112
  const prefixedTypeName = typeName, ///
@@ -129,7 +130,7 @@ export default define(class ComplexTypeDeclaration extends Declaration {
129
130
  return typeVerifies;
130
131
  }
131
132
 
132
- verifySuperType(context, superType, superTypes) {
133
+ verifySuperType(superType, superTypes, context) {
133
134
  let superTypeVerifies = false;
134
135
 
135
136
  const superTypeString = superType.getString(),
@@ -171,7 +172,7 @@ export default define(class ComplexTypeDeclaration extends Declaration {
171
172
  context.trace(`Verifying the '${complexTypeDeclarationString}' complex type declaration's super-types...`);
172
173
 
173
174
  superTypesVerify = this.superTypes.every((superType) => {
174
- const superTypeVerifies = this.verifySuperType(context, superType, superTypes);
175
+ const superTypeVerifies = this.verifySuperType(superType, superTypes, context);
175
176
 
176
177
  if (superTypeVerifies) {
177
178
  return true;
@@ -54,6 +54,13 @@ export default define(class SimpleTypeDeclaration extends Declaration {
54
54
  const propertiesVerifies = this.verifyProperties(context);
55
55
 
56
56
  if (propertiesVerifies) {
57
+ const typePrefix = context.getTypePrefix(),
58
+ prefixName = typePrefix.getPrefixName();
59
+
60
+ this.type.setProvisional(this.provisional);
61
+
62
+ this.type.setPrefixName(prefixName);
63
+
57
64
  context.addType(this.type);
58
65
 
59
66
  verifies = true;
@@ -85,8 +92,6 @@ export default define(class SimpleTypeDeclaration extends Declaration {
85
92
  typePresent = context.isTypePresentByPrefixedTypeName(prefixedTypeName);
86
93
 
87
94
  if (!typePresent) {
88
- this.type.setProvisional(this.provisional);
89
-
90
95
  typeVerifies = true;
91
96
  } else {
92
97
  context.debug(`The '${typeString}' type is already present.`);
@@ -102,7 +107,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
102
107
  return typeVerifies;
103
108
  }
104
109
 
105
- verifySuperType(context, superType, superTypes) {
110
+ verifySuperType(superType, superTypes, context) {
106
111
  let superTypeVerifies = false;
107
112
 
108
113
  const superTypeString = superType.getString(),
@@ -144,7 +149,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
144
149
  context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's super-types...`);
145
150
 
146
151
  superTypesVerify = this.superTypes.every((superType) => {
147
- const superTypeVerifies = this.verifySuperType(context, superType, superTypes);
152
+ const superTypeVerifies = this.verifySuperType(superType, superTypes, context);
148
153
 
149
154
  if (superTypeVerifies) {
150
155
  return true;
@@ -31,7 +31,8 @@ export default define(class TypePrefixDeclaration extends Declaration {
31
31
 
32
32
  context.trace(`Verifying the '${typePrefixDeclarationString}' type prefix declaration...`);
33
33
 
34
- const types = context.getTypes(),
34
+ const includeRelease = false,
35
+ types = context.getTypes(includeRelease),
35
36
  typesLength = types.length;
36
37
 
37
38
  if (typesLength === 0) {
@@ -122,7 +122,7 @@ export default define(class Property extends Element {
122
122
  return validProperty;
123
123
  }
124
124
 
125
- validate(context) {
125
+ validate(context, validateForwards) {
126
126
  let property = null;
127
127
 
128
128
  const propertyString = this.getString(); ///
@@ -135,14 +135,24 @@ export default define(class Property extends Element {
135
135
  property = validProperty; ///
136
136
 
137
137
  context.debug(`...the '${propertyString}' property is already valid.`);
138
+
139
+ const validatesForward = validateForwards(property);
140
+
141
+ if (!validatesForward) {
142
+ property = null;
143
+ }
138
144
  } else {
139
145
  let validates = false;
140
146
 
141
- debugger
147
+ property = this; ///
142
148
 
143
- if (validates) {
144
- const property = this; ///
149
+ const validatesForward = validateForwards(property);
145
150
 
151
+ if (validatesForward) {
152
+ validates = true;
153
+ }
154
+
155
+ if (validates) {
146
156
  context.addProperty(property);
147
157
 
148
158
  context.debug(`...validated the '${propertyString}' property.`);
@@ -152,6 +162,51 @@ export default define(class Property extends Element {
152
162
  return property;
153
163
  }
154
164
 
165
+ validateGivenType(type, context) {
166
+ let property;
167
+
168
+ const typeString = type.getString(),
169
+ propertyString = this.getString(); ///
170
+
171
+ context.trace(`Validating the '${propertyString}' property given the '${typeString}' type...`);
172
+
173
+ let validatesGivenType = false;
174
+
175
+ property = this.validate(context, (property) => {
176
+ let validatesForwards = false;
177
+
178
+ const propertyName = this.name, ///
179
+ typeProperties = type.getProperties(),
180
+ typeProperty = typeProperties.find((typeProperty) => {
181
+ const typePropertyComparesToPropertyName = typeProperty.comparePropertyName(propertyName);
182
+
183
+ if (typePropertyComparesToPropertyName) {
184
+ return true;
185
+ }
186
+ }) || null;
187
+
188
+ if (typeProperty !== null) {
189
+ const type = typeProperty.getType();
190
+
191
+ property.setType(type);
192
+
193
+ validatesForwards = true;
194
+ }
195
+
196
+ return validatesForwards;
197
+ });
198
+
199
+ if (property !== null) {
200
+ validatesGivenType = true;
201
+ }
202
+
203
+ if (validatesGivenType) {
204
+ context.debug(`...validated the '${propertyString}' property given the '${typeString}' type.`);
205
+ }
206
+
207
+ return property;
208
+ }
209
+
155
210
  toJSON() {
156
211
  const typeJSON = typeToTypeJSON(this.type),
157
212
  string = this.getString(),
@@ -30,6 +30,8 @@ export default define(class PropertyRelation extends Element {
30
30
  return propertyRelationNode;
31
31
  }
32
32
 
33
+ getType() { return this.property.getType(); }
34
+
33
35
  isEqualTo(propertyRelation) {
34
36
  const propertyRelationNode = propertyRelation.getNode(),
35
37
  propertyRelationNodeMatches = this.matchPropertyRelationNode(propertyRelationNode),
@@ -73,15 +75,13 @@ export default define(class PropertyRelation extends Element {
73
75
  const termValidates = this.validateTerm(context);
74
76
 
75
77
  if (termValidates) {
76
- const propertyVerifies = this.verifyProperty(context);
78
+ const propertyValidates = this.validateProperty(context);
77
79
 
78
- validates = propertyVerifies;
80
+ validates = propertyValidates;
79
81
  }
80
82
 
81
83
  if (validates) {
82
- const propertyRelation = this; ///
83
-
84
- this.assign(context);
84
+ propertyRelation = this; ///
85
85
 
86
86
  context.addPropertyRelation(propertyRelation);
87
87
 
@@ -118,38 +118,27 @@ export default define(class PropertyRelation extends Element {
118
118
  return termValidates;
119
119
  }
120
120
 
121
- verifyProperty(context) {
122
- let propertyVerifies;
123
-
124
- const propertyString = this.property.getString();
121
+ validateProperty(context) {
122
+ let propertyValidates = false;
125
123
 
126
- context.trace(`Verifying the '${propertyString}' property...`);
124
+ const propertyRelationString = this.getString(); ///
127
125
 
128
- const termType = this.term.getType(),
129
- propertyName = this.property.getName(),
130
- termTypeProperties = termType.getProperties(),
131
- variableTypeProperty = termTypeProperties.find((termTypeProperty) => {
132
- const termTypePropertyComparesToPropertyName = termTypeProperty.comparePropertyName(propertyName);
126
+ context.trace(`Validating the '${propertyRelationString}' property relation's property...`);
133
127
 
134
- if (termTypePropertyComparesToPropertyName) {
135
- return true;
136
- }
137
- }) || null;
128
+ const type = this.term.getType(),
129
+ property = this.property.validateGivenType(type, context);
138
130
 
139
- if (variableTypeProperty === null) {
140
- const variableString = this.term.getString(),
141
- variableTypeString = termType.getString();
131
+ if (property !== null) {
132
+ this.property = property;
142
133
 
143
- context.debug(`The '${propertyName}' property is not a property of the '${variableString}' variable's '${variableTypeString}' type.`);
144
- } else {
145
- propertyVerifies = true;
134
+ propertyValidates = true;
146
135
  }
147
136
 
148
- if (propertyVerifies) {
149
- context.debug(`...verified the '${propertyString}' property.`);
137
+ if (propertyValidates) {
138
+ context.trace(`...validated the '${propertyRelationString}' property relation's property.`);
150
139
  }
151
140
 
152
- return propertyVerifies;
141
+ return propertyValidates;
153
142
  }
154
143
 
155
144
  static name = "PropertyRelation";
@@ -95,7 +95,7 @@ export default define(class Rule extends Element {
95
95
  return verifies;
96
96
  }
97
97
 
98
- verifyLabel(context, label) {
98
+ verifyLabel(label, context) {
99
99
  let labelVerifies;
100
100
 
101
101
  const ruleString = this.getString(), ///
@@ -120,7 +120,7 @@ export default define(class Rule extends Element {
120
120
  context.trace(`Verifying the '${ruleString}' rule's labels...`);
121
121
 
122
122
  labelsVerify = this.labels.every((label) => {
123
- const labelVerifies = this.verifyLabel(context, label);
123
+ const labelVerifies = this.verifyLabel(label, context);
124
124
 
125
125
  if (labelVerifies) {
126
126
  return true;
@@ -6,9 +6,16 @@ import { arrayUtilities } from "necessary";
6
6
  import { define } from "../elements";
7
7
  import { instantiate } from "../utilities/context";
8
8
  import { instantiateType } from "../process/instantiate";
9
+ import { nameFromTypeNode } from "../utilities/element";
9
10
  import { baseTypeFromNothing } from "../utilities/type";
10
- import { nameFromTypeNode, prefixNameFromTypeNode } from "../utilities/element";
11
- import { superTypesFromJSON, provisionalFromJSON, propertiesFromJSON, provisionalToProvisionalJSON, superTypesToSuperTypesJSON, propertiesToPropertiesJSON } from "../utilities/json";
11
+ import { propertiesFromJSON,
12
+ prefixNameFromJSON,
13
+ superTypesFromJSON,
14
+ provisionalFromJSON,
15
+ prefixnameToPrevixNameJSON,
16
+ superTypesToSuperTypesJSON,
17
+ propertiesToPropertiesJSON,
18
+ provisionalToProvisionalJSON } from "../utilities/json";
12
19
 
13
20
  const { push, first } = arrayUtilities;
14
21
 
@@ -229,8 +236,7 @@ export default define(class Type extends Element {
229
236
  }
230
237
 
231
238
  compareTypeName(typeName) {
232
- const name = this.getName(),
233
- nameTypeName = (name === typeName),
239
+ const nameTypeName = (this.name === typeName),
234
240
  comparesToTypeName = nameTypeName; ///
235
241
 
236
242
  return comparesToTypeName;
@@ -254,8 +260,7 @@ export default define(class Type extends Element {
254
260
  let comparesToNominalTypeName = false;
255
261
 
256
262
  if (!comparesToNominalTypeName) {
257
- const name = this.getName(),
258
- nominalTypeNameName = (nominalTypeName === name);
263
+ const nominalTypeNameName = (this.name === nominalTypeName);
259
264
 
260
265
  if (nominalTypeNameName) {
261
266
  comparesToNominalTypeName = true;
@@ -304,14 +309,17 @@ export default define(class Type extends Element {
304
309
  };
305
310
 
306
311
  if (!abridged) {
307
- const superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
312
+ const prefixNameJSON = prefixnameToPrevixNameJSON(this.prefixName),
313
+ superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
308
314
  propertiesJSON = propertiesToPropertiesJSON(this.properties),
309
315
  provisinoalJSOM = provisionalToProvisionalJSON(this.provisional),
316
+ prefixName = prefixNameJSON, ///
310
317
  superTypes = superTypesJSON, ///
311
318
  properties = propertiesJSON, ///
312
319
  provisional = provisinoalJSOM; ///
313
320
 
314
321
  Object.assign(json, {
322
+ prefixName,
315
323
  superTypes,
316
324
  properties,
317
325
  provisional
@@ -329,7 +337,7 @@ export default define(class Type extends Element {
329
337
  typeNode = instantiateType(string, context),
330
338
  node = typeNode, ///
331
339
  name = nameFromTypeNode(typeNode, context),
332
- prefixName = prefixNameFromTypeNode(typeNode, context),
340
+ prefixName = prefixNameFromJSON(json, context),
333
341
  superTypes = superTypesFromJSON(json, context),
334
342
  properties = propertiesFromJSON(json, context),
335
343
  provisional = provisionalFromJSON(json);
@@ -25,6 +25,12 @@ export default define(class TypePrefix extends Element {
25
25
  return typePrefixNode;
26
26
  }
27
27
 
28
+ getPrefixName() {
29
+ const prefixName = this.name; ///
30
+
31
+ return prefixName;
32
+ }
33
+
28
34
  compareTypePrefixName(typePrefixName) {
29
35
  const comparesToTypePrefixName = (this.name === typePrefixName);
30
36
 
@@ -45,23 +45,9 @@ export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
45
45
  }
46
46
 
47
47
  export function variableAssignmentFromPrepertyAssertion(propertyAssertion, context) {
48
+ const term = propertyAssertion.getTerm(),
49
+ type = propertyAssertion.getType(),
50
+ variableAssignment = variableAssignmentFromTermAndType(term, type, context);
48
51
 
49
- debugger
50
-
51
- // let variable;
52
- //
53
- // const { Variable } = elements,
54
- // termNode = this.term.getNode();
55
- //
56
- // variable = Variable.fromTermNode(termNode, context);
57
- //
58
- // if (variable !== null) {
59
- // const variableIdentifier = variable.getIdentifier();
60
- //
61
- // variable = context.findVariableByVariableIdentifier(variableIdentifier);
62
- //
63
- // variable = Variable.fromVariableAndPropertyRelation(variable, this.propertyRelation);
64
- //
65
- // const variableAssignment = variableAssignmentFromVariable(variable),
66
-
67
- }
52
+ return variableAssignment;
53
+ }
@@ -28,6 +28,7 @@ import { TERM_RULE_NAME,
28
28
  PROPERTY_RELATION_RULE_NAME,
29
29
  DEFINED_ASSERTION_RULE_NAME,
30
30
  TERM_SUBSTITUTION_RULE_NAME,
31
+ PROPERTY_ASSERTION_RULE_NAME,
31
32
  SUBPROOF_ASSERTION_RULE_NAME,
32
33
  FRAME_SUBSTITUTION_RULE_NAME,
33
34
  PROCEDURE_REFERENCE_RULE_NAME,
@@ -65,6 +66,7 @@ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
65
66
  definedAssertionPlaceholderRule = ruleFromRuleName(DEFINED_ASSERTION_RULE_NAME),
66
67
  termSubstitutionPlaceholderRule = ruleFromRuleName(TERM_SUBSTITUTION_RULE_NAME),
67
68
  subproofAssertionlaceholderRule = ruleFromRuleName(SUBPROOF_ASSERTION_RULE_NAME),
69
+ propertyAssertionPlaceholderRule = ruleFromRuleName(PROPERTY_ASSERTION_RULE_NAME),
68
70
  frameSubstitutionPlaceholderRule = ruleFromRuleName(FRAME_SUBSTITUTION_RULE_NAME),
69
71
  procedureReferencelaceholderRule = ruleFromRuleName(PROCEDURE_REFERENCE_RULE_NAME),
70
72
  containedAssertionPlaceholderRule = ruleFromRuleName(CONTAINED_ASSERTION_RULE_NAME),
@@ -149,6 +151,8 @@ export function instantiateTermSubstitution(string, context) { return instantiat
149
151
 
150
152
  export function instantiateSubproofAssertion(string, context) { return instantiate(subproofAssertionlaceholderRule, string, context); }
151
153
 
154
+ export function instantiatePropertyAssertion(string, context) { return instantiate(propertyAssertionPlaceholderRule, string, context); }
155
+
152
156
  export function instantiateFrameSubstitution(string, context) { return instantiate(frameSubstitutionPlaceholderRule, string, context); }
153
157
 
154
158
  export function instantiateProcedureReference(string, context) { return instantiate(procedureReferencelaceholderRule, string, context); }
@@ -407,18 +407,24 @@ export function equalitiesFromJSON(json, context) {
407
407
  return equalities;
408
408
  }
409
409
 
410
+ export function prefixNameFromJSON(json, context) {
411
+ const { prefixName } = json;
412
+
413
+ return prefixName;
414
+ }
415
+
410
416
  export function superTypesFromJSON(json, context) {
411
417
  const { superTypes: superTypesJSON } = json;
412
418
 
413
419
  const superTypes = superTypesJSON.map((superTypeJSON) => {
414
- const json = superTypeJSON, ///
415
- { string } = json,
416
- name = string, ///
417
- type = findTypeByName(name, context),
418
- superType = type; ///
420
+ const json = superTypeJSON, ///
421
+ { string } = json,
422
+ name = string, ///
423
+ type = findTypeByName(name, context),
424
+ superType = type; ///
419
425
 
420
- return superType;
421
- });
426
+ return superType;
427
+ });
422
428
 
423
429
  return superTypes;
424
430
  }
@@ -999,6 +1005,12 @@ export function hypothesesToHypothesesJSON(hypotheses) {
999
1005
  return hypothesesJSON;
1000
1006
  }
1001
1007
 
1008
+ export function prefixnameToPrevixNameJSON(prefixname) {
1009
+ const prefixNameJSON = prefixname; ///
1010
+
1011
+ return prefixNameJSON;
1012
+ }
1013
+
1002
1014
  export function superTypesToSuperTypesJSON(superTypes) {
1003
1015
  const superTypesJSON = superTypes.map((superType) => {
1004
1016
  const abridged = true,