occam-verify-cli 1.0.892 → 1.0.896

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.
@@ -6,6 +6,7 @@ import Context from "../context";
6
6
 
7
7
  import { compressTerms,
8
8
  compressFrames,
9
+ compressProperties,
9
10
  compressEqualities,
10
11
  compressJudgements,
11
12
  compressAssertions,
@@ -13,19 +14,23 @@ import { compressTerms,
13
14
  compressReferences,
14
15
  compressAssumptions,
15
16
  compressMetavariables,
16
- compressSubstitutions,} from "../utilities/synoptic";
17
+ compressSubstitutions,
18
+ compressPropertyRelations,} from "../utilities/synoptic";
17
19
  import { termsFromJSON,
18
20
  framesFromJSON,
19
21
  termsToTermsJSON,
20
22
  framesToFramesJSON,
21
- judgementsFromJSON,
23
+ propertiesFromJSON,
22
24
  equalitiesFromJSON,
25
+ judgementsFromJSON,
23
26
  statementsFromJSON,
24
27
  assertionsFromJSON,
25
28
  referencesFromJSON,
26
29
  assumptionsFromJSON,
27
30
  metavariablesFromJSON,
28
31
  substitutionsFromJSON,
32
+ propertyRelationsFromJSON,
33
+ propertiesToPropertiesJSON,
29
34
  judgementsToJudgementsJSON,
30
35
  equalitiesToEqualitiesJSON,
31
36
  statementsToStatementsJSON,
@@ -33,16 +38,18 @@ import { termsFromJSON,
33
38
  referencesToReferencesJSON,
34
39
  assumptionsToAssumptionsJSON,
35
40
  metavariablesToMetavariablesJSON,
36
- substitutionsToSubstitutionsJSON } from "../utilities/json";
41
+ substitutionsToSubstitutionsJSON,
42
+ propertyRelationsToPropertyRelationsJSON } from "../utilities/json";
37
43
 
38
44
  const { push } = arrayUtilities;
39
45
 
40
46
  export default class MnemicContext extends Context {
41
- constructor(context, terms, frames, equalities, judgements, assertions, statements, references, assumptions, metavariables, substitutions) {
47
+ constructor(context, terms, frames, properties, equalities, judgements, assertions, statements, references, assumptions, metavariables, substitutions, propertyRelations) {
42
48
  super(context);
43
49
 
44
50
  this.terms = terms;
45
51
  this.frames = frames;
52
+ this.properties = properties;
46
53
  this.equalities = equalities;
47
54
  this.judgements = judgements;
48
55
  this.assertions = assertions;
@@ -51,6 +58,7 @@ export default class MnemicContext extends Context {
51
58
  this.assumptions = assumptions;
52
59
  this.metavariables = metavariables;
53
60
  this.substitutions = substitutions;
61
+ this.propertyRelations = propertyRelations;
54
62
  }
55
63
 
56
64
  getTerms(terms = []) {
@@ -77,6 +85,18 @@ export default class MnemicContext extends Context {
77
85
  return frames;
78
86
  }
79
87
 
88
+ getProperties(properties = []) {
89
+ const context = this.getContext();
90
+
91
+ push(properties, this.properties);
92
+
93
+ context.getProperties(properties);
94
+
95
+ compressProperties(context);
96
+
97
+ return properties;
98
+ }
99
+
80
100
  getEqualities(equalities = []) {
81
101
  const context = this.getContext();
82
102
 
@@ -173,6 +193,18 @@ export default class MnemicContext extends Context {
173
193
  return substitutions;
174
194
  }
175
195
 
196
+ getPropertyRelations(propertyRelations = []) {
197
+ const context = this.getContext();
198
+
199
+ push(propertyRelations, this.propertyRelations);
200
+
201
+ context.getPropertyRelations(propertyRelations);
202
+
203
+ compressPropertyRelations(context);
204
+
205
+ return propertyRelations;
206
+ }
207
+
176
208
  addTerm(term) {
177
209
  const context = this, ///
178
210
  termString = term.getString();
@@ -206,6 +238,17 @@ export default class MnemicContext extends Context {
206
238
  context.debug(`...added the '${equalityString}' equality to the mnemic context.`);
207
239
  }
208
240
 
241
+ addProperty(property) {
242
+ const context = this, ///
243
+ propertyString = property.getString();
244
+
245
+ context.trace(`Adding the '${propertyString}' property to the mnemic context...`);
246
+
247
+ this.properties.push(property);
248
+
249
+ context.debug(`...added the '${propertyString}' property to the mnemic context.`);
250
+ }
251
+
209
252
  addJudgement(judgement) {
210
253
  const context = this, ///
211
254
  judgementString = judgement.getString();
@@ -283,6 +326,17 @@ export default class MnemicContext extends Context {
283
326
  context.debug(`...added the '${substitutionString}' substitution to the mnemic context.`);
284
327
  }
285
328
 
329
+ addPropertyRelation(propertyRelation) {
330
+ const context = this, ///
331
+ propertyRelationString = propertyRelation.getString();
332
+
333
+ context.trace(`Adding the '${propertyRelationString}' property relation to the mnemic context...`);
334
+
335
+ this.propertyRelations.push(propertyRelation);
336
+
337
+ context.debug(`...added the '${propertyRelationString}' property relation to the mnemic context.`);
338
+ }
339
+
286
340
  addTerms(terms) {
287
341
  terms.forEach((term) => {
288
342
  this.addTerm(term);
@@ -317,15 +371,28 @@ export default class MnemicContext extends Context {
317
371
 
318
372
  findEqualityByEqualityNode(equalityNode) {
319
373
  const equalities = this.getEqualities(),
320
- equality = equalities.find((equality) => {
321
- const equalityNodeMatches = equality.matchEqualityNode(equalityNode);
374
+ equality = equalities.find((equality) => {
375
+ const equalityNodeMatches = equality.matchEqualityNode(equalityNode);
376
+
377
+ if (equalityNodeMatches) {
378
+ return true;
379
+ }
380
+ }) || null;
381
+
382
+ return equality;
383
+ }
322
384
 
323
- if (equalityNodeMatches) {
385
+ findPropertyByPropertyNode(propertyNode) {
386
+ const properties = this.getProperties(),
387
+ property = properties.find((property) => {
388
+ const propertyNodeMatches = property.matchEqualityNode(propertyNode);
389
+
390
+ if (propertyNodeMatches) {
324
391
  return true;
325
392
  }
326
393
  }) || null;
327
394
 
328
- return equality;
395
+ return property;
329
396
  }
330
397
 
331
398
  findJudgementByJudgementNode(judgementNode) {
@@ -432,6 +499,19 @@ export default class MnemicContext extends Context {
432
499
  return substitution;
433
500
  }
434
501
 
502
+ findPropertyRelationByPropertyRelationNode(propertyRelationNode) {
503
+ const propertyRelations = this.getPropertyRelations(),
504
+ propertyRelation = propertyRelations.find((propertyRelation) => {
505
+ const propertyRelationNodeMatches = propertyRelation.matchEqualityNode(propertyRelationNode);
506
+
507
+ if (propertyRelationNodeMatches) {
508
+ return true;
509
+ }
510
+ }) || null;
511
+
512
+ return propertyRelation;
513
+ }
514
+
435
515
  findVariableByVariableNode(variableNode) {
436
516
  const variableIdentifier = variableNode.getVariableIdentifier(),
437
517
  declaredVariable = this.findDeclaredVariableByVariableIdentifier(variableIdentifier),
@@ -461,6 +541,13 @@ export default class MnemicContext extends Context {
461
541
  return equalityPresent;
462
542
  }
463
543
 
544
+ isPropertyPresentByPropertyNode(propertyNode) {
545
+ const property = this.findPropertyByPropertyNode(propertyNode),
546
+ propertyPresent = (property !== null);
547
+
548
+ return propertyPresent;
549
+ }
550
+
464
551
  isJudgementPresentByJudgementNode(judgementNode) {
465
552
  const judgement = this.findJudgementByJudgementNode(judgementNode),
466
553
  judgementPresent = (judgement !== null);
@@ -510,6 +597,13 @@ export default class MnemicContext extends Context {
510
597
  return substitutionPresent;
511
598
  }
512
599
 
600
+ isPropertyRelationresentByPropertyRelationNode(propertyRelationNode) {
601
+ const propertyRelation = this.findPropertyRelationByPropertyRelationNode(propertyRelationNode),
602
+ propertyRelationresent = (propertyRelation !== null);
603
+
604
+ return propertyRelationresent;
605
+ }
606
+
513
607
  commit(element) {
514
608
  const context = this; ///
515
609
 
@@ -531,14 +625,18 @@ export default class MnemicContext extends Context {
531
625
 
532
626
  this.frames = framesFromJSON(json, context);
533
627
 
628
+ this.properties = propertiesFromJSON(json, context);
629
+
534
630
  this.judgements = judgementsFromJSON(json, context);
535
631
  this.assertions = assertionsFromJSON(json, context);
536
632
  this.substitutions = substitutionsFromJSON(json, context);
633
+ this.propertyRelations = propertyRelationsFromJSON(json, context);
537
634
  }
538
635
 
539
636
  toJSON() {
540
637
  let terms = this.getTerms(),
541
638
  frames = this.getFrames(),
639
+ properties = this.getProperties(),
542
640
  judgements = this.getJudgements(),
543
641
  equalities = this.getEqualities(),
544
642
  statements = this.getStatements(),
@@ -546,10 +644,12 @@ export default class MnemicContext extends Context {
546
644
  references = this.getReferences(),
547
645
  assumptions = this.getAssumptions(),
548
646
  metavariables = this.getMetavariables(),
549
- substitutions = this.getSubstitutions();
647
+ substitutions = this.getSubstitutions(),
648
+ propertyRelations = this.getPropertyRelations();
550
649
 
551
650
  const termsJSON = termsToTermsJSON(terms),
552
651
  framesJSON = framesToFramesJSON(frames),
652
+ propertiesJSON = propertiesToPropertiesJSON(properties),
553
653
  judgementsJSON = judgementsToJudgementsJSON(judgements),
554
654
  equalitiesJSON = equalitiesToEqualitiesJSON(equalities),
555
655
  statementsJSON = statementsToStatementsJSON(statements),
@@ -557,10 +657,12 @@ export default class MnemicContext extends Context {
557
657
  referencesJSON = referencesToReferencesJSON(references),
558
658
  assumptionsJSON = assumptionsToAssumptionsJSON(assumptions),
559
659
  metavariablesJSON = metavariablesToMetavariablesJSON(metavariables),
560
- substitutionsJSON = substitutionsToSubstitutionsJSON(substitutions);
660
+ substitutionsJSON = substitutionsToSubstitutionsJSON(substitutions),
661
+ propertyRelationsJSON = propertyRelationsToPropertyRelationsJSON(propertyRelations);
561
662
 
562
663
  terms = termsJSON; ///
563
664
  frames = framesJSON; ///
665
+ properties = propertiesJSON; ///
564
666
  judgements = judgementsJSON; ///
565
667
  equalities = equalitiesJSON; ///
566
668
  statements = statementsJSON; ///
@@ -569,18 +671,21 @@ export default class MnemicContext extends Context {
569
671
  assumptions = assumptionsJSON; ///
570
672
  metavariables = metavariablesJSON; //
571
673
  substitutions = substitutionsJSON; ///
674
+ propertyRelations = propertyRelationsJSON; ///
572
675
 
573
676
  const json = {
574
677
  terms,
575
678
  frames,
576
- judgements,
679
+ properties,
577
680
  equalities,
681
+ judgements,
578
682
  statements,
579
683
  assertions,
580
684
  references,
581
685
  assumptions,
582
686
  metavariables,
583
- substitutions
687
+ substitutions,
688
+ propertyRelations
584
689
  };
585
690
 
586
691
  return json;
@@ -589,6 +694,7 @@ export default class MnemicContext extends Context {
589
694
  static fromJSON(json, context) {
590
695
  const terms = null,
591
696
  frames = null,
697
+ properties = null,
592
698
  equalities = null,
593
699
  judgements = null,
594
700
  statements = null,
@@ -597,7 +703,8 @@ export default class MnemicContext extends Context {
597
703
  assumptions = null,
598
704
  metavariables = null,
599
705
  substitutions = null,
600
- mnemicContext = new MnemicContext(context, terms, frames, equalities, judgements, assertions, statements, references, assumptions, metavariables, substitutions);
706
+ propertyRelations = null,
707
+ mnemicContext = new MnemicContext(context, terms, frames, properties, equalities, judgements, assertions, statements, references, assumptions, metavariables, substitutions, propertyRelations);
601
708
 
602
709
  mnemicContext.initialise(json);
603
710
 
@@ -607,6 +714,7 @@ export default class MnemicContext extends Context {
607
714
  static fromNothing(context) {
608
715
  const terms = [],
609
716
  frames = [],
717
+ properties = [],
610
718
  equalities = [],
611
719
  judgements = [],
612
720
  statements = [],
@@ -615,7 +723,8 @@ export default class MnemicContext extends Context {
615
723
  assumptions = [],
616
724
  metavariables = [],
617
725
  substitutions = [],
618
- mnemicContext = new MnemicContext(context, terms, frames, equalities, judgements, assertions, statements, references, assumptions, metavariables, substitutions);
726
+ propertyRelations = [],
727
+ mnemicContext = new MnemicContext(context, terms, frames, properties, equalities, judgements, assertions, statements, references, assumptions, metavariables, substitutions, propertyRelations);
619
728
 
620
729
  return mnemicContext;
621
730
  }
@@ -6,6 +6,7 @@ import Context from "../context";
6
6
 
7
7
  import { compressTerms,
8
8
  compressFrames,
9
+ compressProperties,
9
10
  compressEqualities,
10
11
  compressJudgements,
11
12
  compressAssertions,
@@ -13,7 +14,8 @@ import { compressTerms,
13
14
  compressReferences,
14
15
  compressAssumptions,
15
16
  compressMetavariables,
16
- compressSubstitutions,} from "../utilities/synoptic";
17
+ compressSubstitutions,
18
+ compressPropertyRelations,} from "../utilities/synoptic";
17
19
 
18
20
  const { last } = arrayUtilities;
19
21
 
@@ -48,6 +50,16 @@ export default class SynopticContext extends Context {
48
50
  return frames;
49
51
  }
50
52
 
53
+ getProperties(properties = []) {
54
+ this.contexts.forEach((context) => {
55
+ context.getProperties(properties);
56
+ });
57
+
58
+ compressProperties(properties);
59
+
60
+ return properties;
61
+ }
62
+
51
63
  getEqualities(equalities = []) {
52
64
  this.contexts.forEach((context) => {
53
65
  context.getEqualities(equalities);
@@ -128,6 +140,16 @@ export default class SynopticContext extends Context {
128
140
  return substitutions;
129
141
  }
130
142
 
143
+ getPropertyRelations(propertyRelations = []) {
144
+ this.contexts.forEach((context) => {
145
+ context.getPropertyRelations(propertyRelations);
146
+ });
147
+
148
+ compressPropertyRelations(propertyRelations);
149
+
150
+ return propertyRelations;
151
+ }
152
+
131
153
  findTermByTermNode(termNode) {
132
154
  const terms = this.getTerms(),
133
155
  term = terms.find((term) => {
@@ -154,6 +176,19 @@ export default class SynopticContext extends Context {
154
176
  return frame;
155
177
  }
156
178
 
179
+ findPropertyByPropetyNode(propertyNode) {
180
+ const propertys = this.getProperties(),
181
+ property = propertys.find((property) => {
182
+ const propertyNodeMatches = property.matchFrameNode(propertyNode);
183
+
184
+ if (propertyNodeMatches) {
185
+ return true;
186
+ }
187
+ }) || null;
188
+
189
+ return property;
190
+ }
191
+
157
192
  findEqualityByEqualityNode(equalityNode) {
158
193
  const equalities = this.getEqualities(),
159
194
  equality = equalities.find((equality) => {
@@ -271,6 +306,19 @@ export default class SynopticContext extends Context {
271
306
  return substitution;
272
307
  }
273
308
 
309
+ findPropertyRelationByPropertyRelationNode(propertyRelationNode) {
310
+ const propertyRelations = this.getPropertyRelations(),
311
+ propertyRelation = propertyRelations.find((propertyRelation) => {
312
+ const propertyRelationNodeMatches = propertyRelation.matchPropertyRelationNode(propertyRelationNode);
313
+
314
+ if (propertyRelationNodeMatches) {
315
+ return true;
316
+ }
317
+ }) || null;
318
+
319
+ return propertyRelation;
320
+ }
321
+
274
322
  static fromContexts(contexts) {
275
323
  const lastContext = last(contexts),
276
324
  context = lastContext, ///
package/src/context.js CHANGED
@@ -48,6 +48,14 @@ export default class Context extends ContextBase {
48
48
  return judgements;
49
49
  }
50
50
 
51
+ getProperties(properties = []) {
52
+ const context = this.getContext();
53
+
54
+ context.getProperties(properties);
55
+
56
+ return properties;
57
+ }
58
+
51
59
  getEqualities(equalities = []) {
52
60
  const context = this.getContext();
53
61
 
@@ -104,6 +112,14 @@ export default class Context extends ContextBase {
104
112
  return substitutions;
105
113
  }
106
114
 
115
+ getPropertyRelations(propertyRelations = []) {
116
+ const context = this.getContext();
117
+
118
+ context.getPropertyRelations(propertyRelations);
119
+
120
+ return propertyRelations;
121
+ }
122
+
107
123
  getDerivedSubstitutions(derivedSubstitutions = []) {
108
124
  const context = this.getContext();
109
125
 
@@ -115,9 +115,9 @@ export default define(class PropertyAssertion extends Assertion {
115
115
  validateTerm(context) {
116
116
  let termValidates = false;
117
117
 
118
- const termString = this.term.getString();
118
+ const propertyAssertionString = this.getString(); ///
119
119
 
120
- context.trace(`Validating the '${termString}' term...`);
120
+ context.trace(`Validating the '${propertyAssertionString}' property assertion's term...`);
121
121
 
122
122
  const term = this.term.validate(context, (term) => {
123
123
  const validatesForwards = true;
@@ -132,7 +132,7 @@ export default define(class PropertyAssertion extends Assertion {
132
132
  }
133
133
 
134
134
  if (termValidates) {
135
- context.debug(`...validated the '${termString}' term.`);
135
+ context.debug(`...validated the '${propertyAssertionString}' property assertion's term.`);
136
136
  }
137
137
 
138
138
  return termValidates;
@@ -141,9 +141,9 @@ export default define(class PropertyAssertion extends Assertion {
141
141
  validatePropertyRelation(context) {
142
142
  let propertyRelationValidates = false;
143
143
 
144
- const propertyRelationString = this.propertyRelation.getString();
144
+ const propertyAssertionString = this.getString(); ///
145
145
 
146
- context.trace(`Validating the '${propertyRelationString}' property relation...`);
146
+ context.trace(`Validating the '${propertyAssertionString}' property assertion's property relation...`);
147
147
 
148
148
  const propertyRelation = this.propertyRelation.validate(context);
149
149
 
@@ -152,7 +152,7 @@ export default define(class PropertyAssertion extends Assertion {
152
152
  }
153
153
 
154
154
  if (propertyRelationValidates) {
155
- context.debug(`...validated the '${propertyRelationString}' property relation.`);
155
+ context.debug(`...validated the '${propertyAssertionString}' property assertion's property relation.`);
156
156
  }
157
157
 
158
158
  return propertyRelationValidates;
@@ -105,8 +105,7 @@ 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
- includeRelease = true,
109
- typePresent = context.isTypePresentByTypeName(typeName, includeRelease);
108
+ typePresent = context.isTypePresentByTypeName(typeName);
110
109
 
111
110
  if (!typePresent) {
112
111
  const prefixedTypeName = typeName, ///
@@ -36,6 +36,8 @@ export default define(class PropertyDeclaration extends Declaration {
36
36
  const propertyVerifies = this.verifyProperty(properties, context);
37
37
 
38
38
  if (propertyVerifies) {
39
+ this.property.setType(this.type);
40
+
39
41
  verifies = true;
40
42
  }
41
43
  }
@@ -59,10 +61,11 @@ export default define(class PropertyDeclaration extends Declaration {
59
61
  context.trace(`Verifying the '${propertyDeclarationString}' property declaration's '${typeString}' type...`);
60
62
 
61
63
  const typeName = this.type.getName(),
62
- includeRelease = true,
63
- typePresent = context.isTypePresentByTypeName(typeName, includeRelease);
64
+ type = context.findTypeByTypeName(typeName);
65
+
66
+ if (type !== null) {
67
+ this.type = type;
64
68
 
65
- if (typePresent) {
66
69
  typeVerifies = true;
67
70
  } else {
68
71
  context.debug(`The '${typeString}' type is not present.`);
@@ -78,8 +78,7 @@ export default define(class SimpleTypeDeclaration extends Declaration {
78
78
  context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration's '${typeString}' type...`);
79
79
 
80
80
  const typeName = this.type.getName(),
81
- includeRelease = true,
82
- typePresent = context.isTypePresentByTypeName(typeName, includeRelease);
81
+ typePresent = context.isTypePresentByTypeName(typeName);
83
82
 
84
83
  if (!typePresent) {
85
84
  const prefixedTypeName = typeName, ///