occam-verify-cli 1.0.696 → 1.0.702

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.
Files changed (91) hide show
  1. package/lib/action/verify.js +3 -2
  2. package/lib/context/ephemeral.js +14 -5
  3. package/lib/context.js +9 -1
  4. package/lib/element/assertion/contained.js +6 -9
  5. package/lib/element/assertion/defined.js +6 -8
  6. package/lib/element/assertion/property.js +11 -5
  7. package/lib/element/assertion/satisfies.js +9 -3
  8. package/lib/element/assertion/subproof.js +4 -5
  9. package/lib/element/assertion/type.js +12 -7
  10. package/lib/element/assumption.js +22 -4
  11. package/lib/element/combinator.js +6 -6
  12. package/lib/element/conclusion.js +5 -5
  13. package/lib/element/constructor.js +9 -4
  14. package/lib/element/deduction.js +5 -5
  15. package/lib/element/equality.js +26 -1
  16. package/lib/element/frame.js +14 -7
  17. package/lib/element/hypothesis.js +13 -6
  18. package/lib/element/judgement.js +69 -3
  19. package/lib/element/label.js +27 -22
  20. package/lib/element/metaType.js +1 -1
  21. package/lib/element/metavariable.js +4 -4
  22. package/lib/element/parameter.js +7 -7
  23. package/lib/element/procedureCall.js +7 -7
  24. package/lib/element/procedureReference.js +7 -6
  25. package/lib/element/proofAssertion/premise.js +6 -7
  26. package/lib/element/proofAssertion/supposition.js +6 -7
  27. package/lib/element/property.js +12 -4
  28. package/lib/element/propertyRelation.js +28 -6
  29. package/lib/element/reference.js +10 -6
  30. package/lib/element/rule.js +26 -16
  31. package/lib/element/signature.js +59 -19
  32. package/lib/element/statement.js +4 -2
  33. package/lib/element/substitution/frame.js +16 -7
  34. package/lib/element/substitution/reference.js +17 -8
  35. package/lib/element/substitution/statement.js +17 -8
  36. package/lib/element/substitution/term.js +17 -8
  37. package/lib/element/term.js +4 -2
  38. package/lib/element/topLevelAssertion.js +28 -17
  39. package/lib/element/topLevelMetaAssertion.js +7 -8
  40. package/lib/element/type.js +16 -9
  41. package/lib/element/typePrefix.js +13 -6
  42. package/lib/element/variable.js +8 -11
  43. package/lib/process/instantiate.js +75 -11
  44. package/lib/utilities/element.js +101 -7
  45. package/lib/utilities/json.js +15 -1
  46. package/package.json +1 -1
  47. package/src/action/verify.js +3 -1
  48. package/src/context/ephemeral.js +19 -4
  49. package/src/context.js +15 -1
  50. package/src/element/assertion/contained.js +8 -25
  51. package/src/element/assertion/defined.js +7 -14
  52. package/src/element/assertion/property.js +16 -5
  53. package/src/element/assertion/satisfies.js +14 -3
  54. package/src/element/assertion/subproof.js +3 -5
  55. package/src/element/assertion/type.js +16 -8
  56. package/src/element/assumption.js +37 -3
  57. package/src/element/combinator.js +6 -13
  58. package/src/element/conclusion.js +5 -7
  59. package/src/element/constructor.js +13 -6
  60. package/src/element/deduction.js +7 -9
  61. package/src/element/equality.js +43 -0
  62. package/src/element/frame.js +21 -12
  63. package/src/element/hypothesis.js +19 -7
  64. package/src/element/judgement.js +45 -0
  65. package/src/element/label.js +35 -26
  66. package/src/element/metaType.js +1 -1
  67. package/src/element/metavariable.js +3 -6
  68. package/src/element/parameter.js +9 -12
  69. package/src/element/procedureCall.js +9 -12
  70. package/src/element/procedureReference.js +8 -8
  71. package/src/element/proofAssertion/premise.js +8 -14
  72. package/src/element/proofAssertion/supposition.js +6 -12
  73. package/src/element/property.js +20 -6
  74. package/src/element/propertyRelation.js +43 -6
  75. package/src/element/reference.js +16 -9
  76. package/src/element/rule.js +41 -24
  77. package/src/element/signature.js +87 -22
  78. package/src/element/statement.js +5 -2
  79. package/src/element/substitution/frame.js +26 -9
  80. package/src/element/substitution/reference.js +29 -11
  81. package/src/element/substitution/statement.js +27 -10
  82. package/src/element/substitution/term.js +27 -10
  83. package/src/element/term.js +5 -2
  84. package/src/element/topLevelAssertion.js +44 -25
  85. package/src/element/topLevelMetaAssertion.js +7 -8
  86. package/src/element/type.js +30 -19
  87. package/src/element/typePrefix.js +19 -7
  88. package/src/element/variable.js +9 -22
  89. package/src/process/instantiate.js +60 -10
  90. package/src/utilities/element.js +105 -10
  91. package/src/utilities/json.js +13 -1
@@ -9,8 +9,9 @@ import { literally } from "../utilities/context";
9
9
  import { EMPTY_STRING } from "../constants";
10
10
  import { metaTypeToMetaTypeJSON } from "../utilities/json";
11
11
  import { instantiateMetavariable } from "../process/instantiate";
12
+ import { nameFromMetavariableNode } from "../utilities/element";
13
+ import { typeFromJSON, metaTypeFromJSON, typeToTypeJSON } from "../utilities/json";
12
14
  import { unifyMetavariable, unifyMetavariableIntrinsically } from "../process/unify";
13
- import { nameFromJSON, typeFromJSON, nameToNameJSON, metaTypeFromJSON, typeToTypeJSON } from "../utilities/json";
14
15
 
15
16
  export default define(class Metavariable extends Element {
16
17
  constructor(context, string, node, name, type, metaType) {
@@ -439,15 +440,12 @@ export default define(class Metavariable extends Element {
439
440
 
440
441
  toJSON() {
441
442
  const typeJSON = typeToTypeJSON(this.type),
442
- nameJSON = nameToNameJSON(this.name),
443
443
  metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
444
- name = nameJSON, ///
445
444
  type = typeJSON, ///
446
445
  metaType = metaTypeJSON, ///
447
446
  string = this.getString(), ///
448
447
  json = {
449
448
  string,
450
- name,
451
449
  type,
452
450
  metaType
453
451
  };
@@ -462,13 +460,12 @@ export default define(class Metavariable extends Element {
462
460
  const { string } = json,
463
461
  metavariableNode = instantiateMetavariable(string, context),
464
462
  node = metavariableNode, ///
465
- name = nameFromJSON(json, context),
463
+ name = nameFromMetavariableNode(metavariableNode, context),
466
464
  type = typeFromJSON(json, context),
467
465
  metaType = metaTypeFromJSON(json, context),
468
466
  metavariable = new Metavariable(context, string, node, name, type, metaType);
469
467
 
470
468
  return metavariable;
471
-
472
469
  }, context);
473
470
 
474
471
  return metavariable;
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
5
5
  import { define } from "../elements";
6
6
  import { literally } from "../utilities/context";
7
7
  import { instantiateParameter } from "../process/instantiate";
8
- import { nameFromJSON, nameToNameJSON, identifierFromJSON, identifierToIdentifierJSON } from "../utilities/json";
8
+ import { nameFromParaneterNode, identifierFromParameterNode } from "../utilities/element";
9
9
 
10
10
  export default define(class Parameter extends Element {
11
11
  constructor(context, string, node, name, identifier) {
@@ -50,15 +50,9 @@ export default define(class Parameter extends Element {
50
50
  }
51
51
 
52
52
  toJSON() {
53
- const nameJSON = nameToNameJSON(this.name),
54
- identifierJSON = identifierToIdentifierJSON(this.identifier),
55
- name = nameJSON, ///
56
- identifier = identifierJSON, ///
57
- string = this.getString(),
53
+ const string = this.getString(),
58
54
  json = {
59
- string,
60
- name,
61
- identifier
55
+ string
62
56
  };
63
57
 
64
58
  return json;
@@ -71,9 +65,12 @@ export default define(class Parameter extends Element {
71
65
  const { string } = json,
72
66
  parameterNode = instantiateParameter(string, context),
73
67
  node = parameterNode, ///
74
- name = nameFromJSON(json, context),
75
- identifier = identifierFromJSON(json, context),
76
- parameter = new Parameter(context, string, node, name, identifier);
68
+ name = nameFromParaneterNode(parameterNode, context),
69
+ identifier = identifierFromParameterNode(parameterNode, context);
70
+
71
+ context = null;
72
+
73
+ const parameter = new Parameter(context, string, node, name, identifier);
77
74
 
78
75
  return parameter;
79
76
  }, context);
@@ -6,7 +6,7 @@ import { termsUtilities } from "occam-furtle";
6
6
  import { define } from "../elements";
7
7
  import { literally } from "../utilities/context";
8
8
  import { instantiateProcedureCall } from "../process/instantiate";
9
- import { parametersFromJSON, parametersToParametersJSON, procedureReferenceFromJSON, procedureReferenceToProcedureReferenceJSON } from "../utilities/json";
9
+ import { parametersFromProcedureCallNode, procedureReferenceFromProcedureCallNode } from "../utilities/element";
10
10
 
11
11
  const { termsFromPrimitives } = termsUtilities;
12
12
 
@@ -114,15 +114,9 @@ export default define(class ProcedureCall extends Element {
114
114
  }
115
115
 
116
116
  toJSON() {
117
- const parametersJSON = parametersToParametersJSON(this.parameters),
118
- procedureReferenceJSON = procedureReferenceToProcedureReferenceJSON(this.procedureReference),
119
- parameters = parametersJSON, ///
120
- procedureReference = procedureReferenceJSON, ///
121
- string = this.getString(),
117
+ const string = this.getString(),
122
118
  json = {
123
- string,
124
- parameters,
125
- procedureReference
119
+ string
126
120
  };
127
121
 
128
122
  return json;
@@ -135,9 +129,12 @@ export default define(class ProcedureCall extends Element {
135
129
  const { string } = json,
136
130
  procedureCallNode = instantiateProcedureCall(string, context),
137
131
  node = procedureCallNode, ///
138
- parameters = parametersFromJSON(json, context),
139
- procedureReference = procedureReferenceFromJSON(json, context),
140
- procedureCall = new ProcedureCall(context, string, node, parameters, procedureReference);
132
+ parameters = parametersFromProcedureCallNode(json, context),
133
+ procedureReference = procedureReferenceFromProcedureCallNode(json, context);
134
+
135
+ context = null;
136
+
137
+ const procedureCall = new ProcedureCall(context, string, node, parameters, procedureReference);
141
138
 
142
139
  return procedureCall;
143
140
  }, context);
@@ -4,8 +4,8 @@ import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
6
  import { literally } from "../utilities/context";
7
- import { nameFromJSON, nameToNameJSON } from "../utilities/json";
8
7
  import { instantiateProcedureReference } from "../process/instantiate";
8
+ import { nameFromProcedureReferenceNode } from "../utilities/element";
9
9
 
10
10
  export default define(class ProcedureReference extends Element {
11
11
  constructor(context, string, node, name) {
@@ -32,12 +32,9 @@ export default define(class ProcedureReference extends Element {
32
32
  }
33
33
 
34
34
  toJSON() {
35
- const nameJSON = nameToNameJSON(this.name),
36
- name = nameJSON, ///
37
- string = this.getString(),
35
+ const string = this.getString(),
38
36
  json = {
39
- string,
40
- name
37
+ string
41
38
  };
42
39
 
43
40
  return json;
@@ -50,8 +47,11 @@ export default define(class ProcedureReference extends Element {
50
47
  const { string } = json,
51
48
  procedureReferenceNode = instantiateProcedureReference(string, context),
52
49
  node = procedureReferenceNode, ///
53
- name = nameFromJSON(json, context),
54
- procedureReference = new ProcedureReference(context, string, node, name);
50
+ name = nameFromProcedureReferenceNode(procedureReferenceNode, context);
51
+
52
+ context = null;
53
+
54
+ const procedureReference = new ProcedureReference(context, string, node, name);
55
55
 
56
56
  return procedureReference;
57
57
  }, context);
@@ -4,8 +4,9 @@ import ProofAssertion from "../proofAssertion";
4
4
 
5
5
  import { define } from "../../elements";
6
6
  import { instantiatePremise } from "../../process/instantiate";
7
+ import { ephemeralContextFromJSON } from "../../utilities/json";
7
8
  import { attempt, liminally, literally } from "../../utilities/context";
8
- import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, ephemeralContextFromJSON, procedureCallToProcedureCallJSON } from "../../utilities/json";
9
+ import { statementFromPremiseNode, procedureCallFromPremiseNode } from "../../utilities/element";
9
10
 
10
11
  export default define(class Premise extends ProofAssertion {
11
12
  constructor(context, string, node, statement, procedureCall) {
@@ -271,16 +272,10 @@ export default define(class Premise extends ProofAssertion {
271
272
 
272
273
  context = contextJSON; ///
273
274
 
274
- const procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
275
- statementJSON = statementToStatementJSON(this.statement),
276
- procedureCall = procedureCallJSON, ///
277
- statement = statementJSON, ///
278
- string = this.getString(),
275
+ const string = this.getString(),
279
276
  json = {
280
277
  context,
281
- string,
282
- statement,
283
- procedureCall
278
+ string
284
279
  };
285
280
 
286
281
  return json;
@@ -291,10 +286,10 @@ export default define(class Premise extends ProofAssertion {
291
286
  static fromJSON(json, context) {
292
287
  const premise = literally((context) => {
293
288
  const { string } = json,
294
- prmiseNode = instantiatePremise(string, context),
295
- node = prmiseNode, ///
296
- statement = statementFromJSON(json, context),
297
- procedureCall = procedureCallFromJSON(json, context),
289
+ premiseNode = instantiatePremise(string, context),
290
+ node = premiseNode, ///
291
+ statement = statementFromPremiseNode(premiseNode, context),
292
+ procedureCall = procedureCallFromPremiseNode(premiseNode, context),
298
293
  ephemeralContext = ephemeralContextFromJSON(json, context);
299
294
 
300
295
  context = ephemeralContext; ///
@@ -302,7 +297,6 @@ export default define(class Premise extends ProofAssertion {
302
297
  const premise = new Premise(context, string, node, statement, procedureCall);
303
298
 
304
299
  return premise;
305
-
306
300
  }, context);
307
301
 
308
302
  return premise;
@@ -4,8 +4,9 @@ import ProofAssertion from "../proofAssertion";
4
4
 
5
5
  import { define } from "../../elements";
6
6
  import { instantiateSupposition } from "../../process/instantiate";
7
+ import { ephemeralContextFromJSON } from "../../utilities/json";
7
8
  import { attempt, liminally, literally } from "../../utilities/context";
8
- import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, ephemeralContextFromJSON, procedureCallToProcedureCallJSON } from "../../utilities/json";
9
+ import { statementFromSuppositionNode, procedureCallFromSuppositionNode } from "../../utilities/element";
9
10
 
10
11
  export default define(class Supposition extends ProofAssertion {
11
12
  constructor(context, string, node, statement, procedureCall) {
@@ -293,16 +294,10 @@ export default define(class Supposition extends ProofAssertion {
293
294
 
294
295
  context = contextJSON; ///
295
296
 
296
- const procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
297
- statementJSON = statementToStatementJSON(this.statement),
298
- procedureCall = procedureCallJSON, ///
299
- statement = statementJSON, ///
300
- string = this.getString(),
297
+ const string = this.getString(),
301
298
  json = {
302
299
  context,
303
- string,
304
- statement,
305
- procedureCall
300
+ string
306
301
  };
307
302
 
308
303
  return json;
@@ -315,8 +310,8 @@ export default define(class Supposition extends ProofAssertion {
315
310
  const { string } = json,
316
311
  suppositionNode = instantiateSupposition(string, context),
317
312
  node = suppositionNode, ///
318
- statement = statementFromJSON(json, context),
319
- procedureCall = procedureCallFromJSON(json, context),
313
+ statement = statementFromSuppositionNode(suppositionNode, context),
314
+ procedureCall = procedureCallFromSuppositionNode(suppositionNode, context),
320
315
  ephemeralContext = ephemeralContextFromJSON(json, context);
321
316
 
322
317
  context = ephemeralContext; ///
@@ -324,7 +319,6 @@ export default define(class Supposition extends ProofAssertion {
324
319
  const supposition = new Supposition(context, string, node, statement, procedureCall);
325
320
 
326
321
  return supposition;
327
-
328
322
  }, context);
329
323
 
330
324
  return supposition;
@@ -3,7 +3,10 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import {nameToNameJSON} from "../utilities/json";
6
+ import { literally } from "../utilities/context";
7
+ import { instantiateProperty } from "../process/instantiate";
8
+ import { nameFromPropertyNode } from "../utilities/element";
9
+ import { nominalTypeNameFromJSON, nominalTypeNameToNominalTypeNameJSON } from "../utilities/json";
7
10
 
8
11
  export default define(class Property extends Element {
9
12
  constructor(context, string, node, name, nominalTypeName) {
@@ -41,14 +44,11 @@ export default define(class Property extends Element {
41
44
  }
42
45
 
43
46
  toJSON() {
44
- const nominalTypeNameJSON = nameToNameJSON(this.nominalTypeName),
45
- nameJSON = nameToNameJSON(this.name),
47
+ const nominalTypeNameJSON = nominalTypeNameToNominalTypeNameJSON(this.nominalTypeName),
46
48
  nominalTypeName = nominalTypeNameJSON, ///
47
- name = nameJSON, ///
48
49
  string = this.getString(),
49
50
  json = {
50
51
  string,
51
- name,
52
52
  nominalTypeName
53
53
  };
54
54
 
@@ -58,6 +58,20 @@ export default define(class Property extends Element {
58
58
  static name = "Property";
59
59
 
60
60
  static fromJSON(json, context) {
61
- debugger
61
+ const property = literally((context) => {
62
+ const { string } = json,
63
+ propertyNode = instantiateProperty(string, context),
64
+ node = propertyNode, ///
65
+ name = nameFromPropertyNode(propertyNode, context),
66
+ nominalTypeName = nominalTypeNameFromJSON(json);
67
+
68
+ context = null;
69
+
70
+ const property = new Property(context, string, node, name, nominalTypeName);
71
+
72
+ return property;
73
+ }, context);
74
+
75
+ return property;
62
76
  }
63
77
  });
@@ -3,23 +3,26 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
+ import { literally } from "../utilities/context";
7
+ import { instantiatePropertyRelation } from "../process/instantiate";
8
+ import { propertyFromPropertyRelationNode } from "../utilities/element";
6
9
 
7
10
  export default define(class PropertyRelation extends Element {
8
- constructor(context, string, node, property, term) {
11
+ constructor(context, string, node, term, property) {
9
12
  super(context, string, node);
10
13
 
11
- this.property = property;
12
14
  this.term = term;
13
- }
14
-
15
- getProperty() {
16
- return this.property;
15
+ this.property = property;
17
16
  }
18
17
 
19
18
  getTerm() {
20
19
  return this.term;
21
20
  }
22
21
 
22
+ getProperty() {
23
+ return this.property;
24
+ }
25
+
23
26
  getPropertyRelationNode() {
24
27
  const node = this.getNode(),
25
28
  propertyRelationNode = node; ///
@@ -110,4 +113,38 @@ export default define(class PropertyRelation extends Element {
110
113
  }
111
114
 
112
115
  static name = "PropertyRelation";
116
+
117
+ toJSON() {
118
+ const string = this.getString(),
119
+ json = {
120
+ string
121
+ };
122
+
123
+ return json;
124
+ }
125
+
126
+ static fromJSON(json, context) {
127
+ const propertyRelation = literally((context) => {
128
+ const { string } = json,
129
+ propertyRelationNode = instantiatePropertyRelation(string, context),
130
+ node = propertyRelationNode, ///
131
+ term = termFromPropertyRelationNode(propertyRelationNode, context),
132
+ property = propertyFromPropertyRelationNode(propertyRelationNode, context);
133
+
134
+ context = null;
135
+
136
+ const propertyRelation = new PropertyRelation(context, string, node, term, property);
137
+
138
+ return propertyRelation;
139
+ }, context);
140
+
141
+ return propertyRelation;
142
+ }
113
143
  });
144
+
145
+ function termFromPropertyRelationNode(propertyRelationNode, context) {
146
+ const termNode = propertyRelationNode.getTermNode(),
147
+ term = context.findTermByTermNode(termNode);
148
+
149
+ return term;
150
+ }
@@ -3,10 +3,11 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { attempt } from "../utilities/context";
6
+ import { attempt, literally } from "../utilities/context";
7
+ import { instantiateReference } from "../process/instantiate";
7
8
  import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
9
+ import { metavariableFromReferenceNode } from "../utilities/element";
8
10
  import { unifyMetavariableIntrinsically } from "../process/unify";
9
- import { metavariableToMetavariableJSON } from "../utilities/json";
10
11
 
11
12
  export default define(class Reference extends Element {
12
13
  constructor(context, string, node, metavariable) {
@@ -26,7 +27,6 @@ export default define(class Reference extends Element {
26
27
  return referenceNode;
27
28
  }
28
29
 
29
-
30
30
  getName() { return this.metavariable.getName(); }
31
31
 
32
32
  getMetavariableName() {
@@ -291,12 +291,9 @@ export default define(class Reference extends Element {
291
291
  }
292
292
 
293
293
  toJSON() {
294
- const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
295
- metavariable = metavariableJSON, ///
296
- string = this.getString(),
294
+ const string = this.getString(),
297
295
  json = {
298
- string,
299
- metavariable
296
+ string
300
297
  };
301
298
 
302
299
  return json;
@@ -305,6 +302,16 @@ export default define(class Reference extends Element {
305
302
  static name = "Reference";
306
303
 
307
304
  static fromJSON(json, context) {
308
- debugger
305
+ const reference = literally((context) => {
306
+ const { string } = json,
307
+ referenceNode = instantiateReference(string, context),
308
+ node = referenceNode, ///
309
+ metavariable = metavariableFromReferenceNode(referenceNode, context),
310
+ reference = new Reference(context, string, node, metavariable);
311
+
312
+ return reference;
313
+ }, context);
314
+
315
+ return reference;
309
316
  }
310
317
  });
@@ -55,30 +55,6 @@ export default define(class Rule extends Element {
55
55
  return comparesToMetavariableName;
56
56
  }
57
57
 
58
- verifyLabels() {
59
- let labelsVerify;
60
-
61
- const context = this.getContext(),
62
- ruleString = this.getString(); ///
63
-
64
- context.trace(`Verifying the '${ruleString}' rule's labels...`);
65
-
66
- labelsVerify = this.labels.every((label) => {
67
- const nameOnly = true,
68
- labelVerifies = label.verify(nameOnly);
69
-
70
- if (labelVerifies) {
71
- return true;
72
- }
73
- });
74
-
75
- if (labelsVerify) {
76
- context.debug(`...verified the '${ruleString}' rule's labels.`);
77
- }
78
-
79
- return labelsVerify;
80
- }
81
-
82
58
  unifyStatementWithConclusion(statement, context) {
83
59
  let statementUnifiesWithConclusion = false;
84
60
 
@@ -143,6 +119,47 @@ export default define(class Rule extends Element {
143
119
  return verifies;
144
120
  }
145
121
 
122
+ verifyLabel(label) {
123
+ let labelVerifies;
124
+
125
+ const context = this.getContext(),
126
+ ruleString = this.getString(), ///
127
+ labelString = label.getString();
128
+
129
+ context.trace(`Verifying the '${ruleString}' rule's '${labelString}' label...`);
130
+
131
+ labelVerifies = label.verify();
132
+
133
+ if (labelVerifies) {
134
+ context.debug(`...verified the '${ruleString}' rule's '${labelString}' label.`);
135
+ }
136
+
137
+ return labelVerifies;
138
+ }
139
+
140
+ verifyLabels() {
141
+ let labelsVerify;
142
+
143
+ const context = this.getContext(),
144
+ ruleString = this.getString(); ///
145
+
146
+ context.trace(`Verifying the '${ruleString}' rule's labels...`);
147
+
148
+ labelsVerify = this.labels.every((label) => {
149
+ const labelVerifies = this.verifyLabel(label);
150
+
151
+ if (labelVerifies) {
152
+ return true;
153
+ }
154
+ });
155
+
156
+ if (labelsVerify) {
157
+ context.debug(`...verified the '${ruleString}' rule's labels.`);
158
+ }
159
+
160
+ return labelsVerify;
161
+ }
162
+
146
163
  async verifyProof(context) {
147
164
  let proofVerifies;
148
165
 
@@ -4,8 +4,9 @@ import { Element } from "occam-languages";
4
4
  import { arrayUtilities } from "necessary";
5
5
 
6
6
  import { define } from "../elements";
7
- import { signatureStringFromTerms } from "../utilities/string";
8
- import { termsFromJSON, termsToTermsJSON } from "../utilities/json";
7
+ import { literally } from "../utilities/context";
8
+ import { instantiateSignature } from "../process/instantiate";
9
+ import { termsFromSignatureNode } from "../utilities/element";
9
10
 
10
11
  const { match, compare, correlate } = arrayUtilities;
11
12
 
@@ -34,34 +35,89 @@ export default define(class Signature extends Element {
34
35
 
35
36
  context.trace(`Verifying the '${signatureString}' signature...`);
36
37
 
37
- const terms = [],
38
- termsValidate = this.terms.every((term) => {
39
- term = term.validate(context, () => { ///
40
- const validatesForwards = true;
38
+ const validates = this.validate(context);
41
39
 
42
- return validatesForwards;
43
- });
40
+ if (validates) {
41
+ verifies = true;
42
+ }
44
43
 
45
- const termValidates = (term !== null);
44
+ if (verifies) {
45
+ context.debug(`...verified the '${signatureString}' signature.`);
46
+ }
46
47
 
47
- if (termValidates) {
48
- terms.push(term);
48
+ return verifies;
49
+ }
49
50
 
50
- return true;
51
- }
52
- });
51
+ validate(context) {
52
+ let validates = false;
53
+
54
+ const signatureString = this.getString(); ///
55
+
56
+ context.trace(`Validating the '${signatureString}' signature...`);
57
+
58
+ const terms = [],
59
+ termsValidate = this.validateTerms(terms, context);
53
60
 
54
61
  if (termsValidate) {
55
62
  this.terms = terms;
56
63
 
57
- verifies = true;
64
+ validates = true;
58
65
  }
59
66
 
60
- if (verifies) {
61
- context.debug(`...verified the '${signatureString}' signature.`);
67
+ if (validates) {
68
+ context.debug(`...validated the '${signatureString}' signature.`);
62
69
  }
63
70
 
64
- return verifies;
71
+ return validates
72
+ }
73
+
74
+ validateTerm(term, terms, context) {
75
+ let termValidates = false;
76
+
77
+ const termString = term.getString(),
78
+ signatureString = this.getString(); ///
79
+
80
+ context.trace(`Validating the '${signatureString}' signature's '${termString}' term...`);
81
+
82
+ term = term.validate(context, () => { ///
83
+ const validatesForwards = true;
84
+
85
+ return validatesForwards;
86
+ });
87
+
88
+ if (term !== null) {
89
+ terms.push(term);
90
+
91
+ termValidates = true;
92
+ }
93
+
94
+ if (termValidates) {
95
+ context.debug(`...validated the '${signatureString}' signature's '${termString}' term.`);
96
+ }
97
+
98
+ return termValidates
99
+ }
100
+
101
+ validateTerms(terms, context) {
102
+ let termsValidate;
103
+
104
+ const signatureString = this.getString(); ///
105
+
106
+ context.trace(`Validating the '${signatureString}' signature's terms...`);
107
+
108
+ termsValidate = terms.every((term) => {
109
+ const termValidates = this.validateTerm(term, terms, context);
110
+
111
+ if (termValidates) {
112
+ return true;
113
+ }
114
+ })
115
+
116
+ if (termsValidate){
117
+ context.debug(`...validated the '${signatureString}' signature's terms.`);
118
+ }
119
+
120
+ return termsValidate
65
121
  }
66
122
 
67
123
  compare(signature, substitutions, generalContext, specificContext) {
@@ -158,10 +214,9 @@ export default define(class Signature extends Element {
158
214
  }
159
215
 
160
216
  toJSON() {
161
- const termsJSON = termsToTermsJSON(this.terms),
162
- terms = termsJSON, ///
217
+ const string = this.getString(),
163
218
  json = {
164
- terms
219
+ string
165
220
  };
166
221
 
167
222
  return json;
@@ -170,6 +225,16 @@ export default define(class Signature extends Element {
170
225
  static name = "Signature";
171
226
 
172
227
  static fromJSON(json, context) {
173
- debugger
228
+ const signature = literally((context) => {
229
+ const { string } = json,
230
+ signatureNode = instantiateSignature(string, context),
231
+ node = signatureNode, ///
232
+ terms = termsFromSignatureNode(signatureNode, context),
233
+ signature = new Signature(context, string, node, terms);
234
+
235
+ return signature;
236
+ }, context);
237
+
238
+ return signature;
174
239
  }
175
240
  });