occam-verify-cli 1.0.388 → 1.0.396

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 (119) hide show
  1. package/lib/action/verify.js +3 -3
  2. package/lib/context/file.js +8 -7
  3. package/lib/context/local.js +23 -57
  4. package/lib/context/temporary.js +705 -0
  5. package/lib/mixins/statement/verify.js +38 -16
  6. package/lib/mixins/step/unify.js +3 -3
  7. package/lib/node/substitution/frame.js +23 -1
  8. package/lib/node/substitution/term.js +23 -1
  9. package/lib/ontology/assertion/contained.js +77 -35
  10. package/lib/ontology/assertion/defined.js +76 -34
  11. package/lib/ontology/assertion/property.js +71 -29
  12. package/lib/ontology/assertion/satisfies.js +70 -22
  13. package/lib/ontology/assertion/subproof.js +95 -41
  14. package/lib/ontology/assertion/type.js +74 -18
  15. package/lib/ontology/assertion.js +66 -0
  16. package/lib/ontology/axiom.js +8 -11
  17. package/lib/ontology/combinator/bracketed.js +17 -3
  18. package/lib/ontology/combinator.js +17 -3
  19. package/lib/ontology/conclusion.js +38 -9
  20. package/lib/ontology/constructor/bracketed.js +17 -3
  21. package/lib/ontology/constructor.js +17 -3
  22. package/lib/ontology/declaration.js +27 -2
  23. package/lib/ontology/deduction.js +38 -9
  24. package/lib/ontology/frame.js +50 -13
  25. package/lib/ontology/hypothesis.js +11 -11
  26. package/lib/ontology/judgement.js +1 -1
  27. package/lib/ontology/label.js +5 -6
  28. package/lib/ontology/metavariable.js +11 -12
  29. package/lib/ontology/premise.js +47 -17
  30. package/lib/ontology/procedureCall.js +15 -15
  31. package/lib/ontology/procedureReference.js +1 -1
  32. package/lib/ontology/proof.js +2 -2
  33. package/lib/ontology/reference.js +4 -5
  34. package/lib/ontology/rule.js +68 -69
  35. package/lib/ontology/section.js +2 -2
  36. package/lib/ontology/signature.js +2 -2
  37. package/lib/ontology/statement.js +9 -1
  38. package/lib/ontology/step.js +37 -24
  39. package/lib/ontology/subproof.js +11 -11
  40. package/lib/ontology/substitution/frame.js +69 -21
  41. package/lib/ontology/substitution/reference.js +24 -9
  42. package/lib/ontology/substitution/statement.js +99 -79
  43. package/lib/ontology/substitution/term.js +89 -29
  44. package/lib/ontology/substitution.js +37 -30
  45. package/lib/ontology/supposition.js +56 -25
  46. package/lib/ontology/term.js +4 -3
  47. package/lib/ontology/topLevelAssertion.js +15 -15
  48. package/lib/ontology/topLevelMetaAssertion.js +2 -2
  49. package/lib/ontology/variable.js +42 -14
  50. package/lib/substitutions.js +25 -25
  51. package/lib/unifier/intrinsicLevel.js +14 -7
  52. package/lib/unifier/metaLevel.js +25 -17
  53. package/lib/utilities/brackets.js +4 -21
  54. package/lib/utilities/context.js +6 -6
  55. package/lib/utilities/json.js +24 -1
  56. package/lib/utilities/metavariable.js +18 -0
  57. package/lib/utilities/substitutions.js +3 -3
  58. package/lib/utilities/unification.js +10 -16
  59. package/lib/utilities/variable.js +30 -0
  60. package/package.json +2 -2
  61. package/src/action/verify.js +2 -2
  62. package/src/context/file.js +8 -7
  63. package/src/context/local.js +13 -61
  64. package/src/context/temporary.js +394 -0
  65. package/src/mixins/statement/verify.js +60 -23
  66. package/src/mixins/step/unify.js +2 -2
  67. package/src/node/substitution/frame.js +26 -0
  68. package/src/node/substitution/term.js +26 -0
  69. package/src/ontology/assertion/contained.js +12 -23
  70. package/src/ontology/assertion/defined.js +12 -23
  71. package/src/ontology/assertion/property.js +7 -20
  72. package/src/ontology/assertion/satisfies.js +7 -16
  73. package/src/ontology/assertion/subproof.js +36 -42
  74. package/src/ontology/assertion/type.js +10 -11
  75. package/src/ontology/assertion.js +23 -0
  76. package/src/ontology/axiom.js +7 -16
  77. package/src/ontology/combinator/bracketed.js +2 -0
  78. package/src/ontology/combinator.js +2 -0
  79. package/src/ontology/conclusion.js +51 -10
  80. package/src/ontology/constructor/bracketed.js +2 -0
  81. package/src/ontology/constructor.js +2 -0
  82. package/src/ontology/declaration.js +34 -1
  83. package/src/ontology/deduction.js +51 -10
  84. package/src/ontology/frame.js +58 -21
  85. package/src/ontology/hypothesis.js +8 -8
  86. package/src/ontology/judgement.js +1 -1
  87. package/src/ontology/label.js +2 -7
  88. package/src/ontology/metavariable.js +12 -15
  89. package/src/ontology/premise.js +64 -21
  90. package/src/ontology/procedureCall.js +14 -14
  91. package/src/ontology/procedureReference.js +2 -2
  92. package/src/ontology/proof.js +1 -1
  93. package/src/ontology/reference.js +1 -6
  94. package/src/ontology/rule.js +76 -80
  95. package/src/ontology/section.js +1 -1
  96. package/src/ontology/signature.js +1 -1
  97. package/src/ontology/statement.js +6 -0
  98. package/src/ontology/step.js +43 -26
  99. package/src/ontology/subproof.js +8 -8
  100. package/src/ontology/substitution/frame.js +72 -26
  101. package/src/ontology/substitution/reference.js +8 -6
  102. package/src/ontology/substitution/statement.js +93 -77
  103. package/src/ontology/substitution/term.js +108 -42
  104. package/src/ontology/substitution.js +27 -22
  105. package/src/ontology/supposition.js +70 -24
  106. package/src/ontology/term.js +5 -5
  107. package/src/ontology/topLevelAssertion.js +14 -16
  108. package/src/ontology/topLevelMetaAssertion.js +1 -1
  109. package/src/ontology/variable.js +64 -17
  110. package/src/substitutions.js +25 -25
  111. package/src/unifier/intrinsicLevel.js +18 -8
  112. package/src/unifier/metaLevel.js +35 -21
  113. package/src/utilities/brackets.js +3 -29
  114. package/src/utilities/context.js +5 -5
  115. package/src/utilities/json.js +28 -0
  116. package/src/utilities/metavariable.js +13 -0
  117. package/src/utilities/substitutions.js +2 -4
  118. package/src/utilities/unification.js +8 -24
  119. package/src/utilities/variable.js +22 -0
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  import ontology from "../../ontology";
4
+ import Assertion from "../assertion";
4
5
  import VariableAssignment from "../../assignment/variable";
5
6
 
6
7
  import { define } from "../../ontology";
7
8
 
8
- export default define(class TypeAssertion {
9
- constructor(string, term, type) {
10
- this.string = string;
9
+ export default define(class TypeAssertion extends Assertion {
10
+ constructor(string, node, tokens, term, type) {
11
+ super(string, node, tokens);
12
+
11
13
  this.term = term;
12
14
  this.type = type;
13
15
  }
14
16
 
15
- getString() {
16
- return this.string;
17
- }
18
-
19
17
  getTerm() {
20
18
  return this.term;
21
19
  }
@@ -27,7 +25,7 @@ export default define(class TypeAssertion {
27
25
  verify(assignments, stated, context) {
28
26
  let verifies = false;
29
27
 
30
- let typeAssertionString = this.string; ///
28
+ let typeAssertionString = this.getString(); ///
31
29
 
32
30
  context.trace(`Verifying the '${typeAssertionString}' type assertion...`);
33
31
 
@@ -89,7 +87,7 @@ export default define(class TypeAssertion {
89
87
  verifyWhenStated(assignments, context) {
90
88
  let verifiesWhenStated = false;
91
89
 
92
- const typeAssertionString = this.string; ///
90
+ const typeAssertionString = this.getString(); ///
93
91
 
94
92
  context.trace(`Verifying the '${typeAssertionString}' stated type assertion...`);
95
93
 
@@ -120,7 +118,7 @@ export default define(class TypeAssertion {
120
118
  verifyWhenDerived(context) {
121
119
  let verifiesWhenDerived;
122
120
 
123
- const typeAssertionString = this.string; ///
121
+ const typeAssertionString = this.getString(); ///
124
122
 
125
123
  context.trace(`Verifying the '${typeAssertionString}' derived type assertion...`);
126
124
 
@@ -191,11 +189,12 @@ export default define(class TypeAssertion {
191
189
  if (typeAssertionNode !== null) {
192
190
  const { Term, Type } = ontology,
193
191
  node = typeAssertionNode, ///
192
+ tokens = null,
194
193
  string = context.nodeAsString(node),
195
194
  term = Term.fromTypeAssertionNode(typeAssertionNode, context),
196
195
  type = Type.fromTypeAssertionNode(typeAssertionNode, context);
197
196
 
198
- typeAssertion = new TypeAssertion(string, term, type);
197
+ typeAssertion = new TypeAssertion(string, node, tokens, term, type);
199
198
  }
200
199
 
201
200
  return typeAssertion;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ export default class Assertion {
4
+ constructor(string, node, tokens) {
5
+ this.string = string;
6
+ this.node = node;
7
+ this.tokens = tokens;
8
+ }
9
+
10
+ getString() {
11
+ return this.string;
12
+ }
13
+
14
+ getNode() {
15
+ return this.node;
16
+ }
17
+
18
+ getTokens() {
19
+ return this.tokens;
20
+ }
21
+
22
+ matchAssertionNode(assertionNode) { return this.node.match(assertionNode); }
23
+ }
@@ -82,6 +82,8 @@ export default define(class Axiom extends TopLevelAssertion {
82
82
  unifyStep(step, substitutions, context) {
83
83
  let stepUnifies = false;
84
84
 
85
+ context = step.getContext();
86
+
85
87
  const node = this.getNode(),
86
88
  stepString = step.getString(),
87
89
  axiomString = this.getString();
@@ -94,12 +96,7 @@ export default define(class Axiom extends TopLevelAssertion {
94
96
  context.trace(`Cannot unify the '${stepString}' step with the '${axiomString}' axiom because the axiom is not unconditional.`, node);
95
97
  } else {
96
98
  const statement = step.getStatement(),
97
- specificContext = context; ///
98
-
99
- context = this.getContext();
100
-
101
- const generalContext = context, ///
102
- statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
99
+ statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, context);
103
100
 
104
101
  if (statementUnifiesWithDeduction) {
105
102
  stepUnifies = true;
@@ -113,18 +110,17 @@ export default define(class Axiom extends TopLevelAssertion {
113
110
  return stepUnifies;
114
111
  }
115
112
 
116
- unifyLastStep(lastStep, substitutions, generalContext, specificContext) {
113
+ unifyLastStep(lastStep, substitutions, context) {
117
114
  let lastStepUnifies = false;
118
115
 
119
116
  const node = this.getNode(),
120
- context = specificContext, ///
121
117
  axiomString = this.getString(),
122
118
  lastStepString = lastStep.getString();
123
119
 
124
120
  context.trace(`Unifying the '${lastStepString}' last step with the '${axiomString}' axiom...`, node)
125
121
 
126
122
  const statement = lastStep.getStatement(),
127
- statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
123
+ statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, context);
128
124
 
129
125
  if (statementUnifiesWithDeduction) {
130
126
  lastStepUnifies = true;
@@ -152,16 +148,11 @@ export default define(class Axiom extends TopLevelAssertion {
152
148
  context.trace(`Cannot unify the '${subproofString}' subproof with the '${axiomString}' axiom because the axiom is unconditional.`, node);
153
149
  } else {
154
150
  const lastStep = subproof.getLastStep(),
155
- specificContext = context; ///
156
-
157
- context = this.getContext();
158
-
159
- const generalContext = context, ///
160
- lastStepUnifies = this.unifyLastStep(lastStep, substitutions, generalContext, specificContext);
151
+ lastStepUnifies = this.unifyLastStep(lastStep, substitutions, context);
161
152
 
162
153
  if (lastStepUnifies) {
163
154
  const suppositions = subproof.getSuppositions(),
164
- suppositionsUnify = this.unifySuppositions(suppositions, substitutions, generalContext, specificContext);
155
+ suppositionsUnify = this.unifySuppositions(suppositions, substitutions, context);
165
156
 
166
157
  if (suppositionsUnify) {
167
158
  subproofUnifies = true;
@@ -23,6 +23,8 @@ export default define(class BracketedCombinator extends Combinator {
23
23
  return statementUnifies;
24
24
  }
25
25
 
26
+ static name = "BracketedCombinator";
27
+
26
28
  static fromNothing() {
27
29
  const { Statement } = ontology,
28
30
  bracketedStatementNode = combinatorBracketedContext.getBracketedStatementNode(),
@@ -53,6 +53,8 @@ export default define(class Combinator {
53
53
  return json;
54
54
  }
55
55
 
56
+ static name = "Combinator";
57
+
56
58
  static fromJSON(json, context) {
57
59
  const statement = statementFromJSON(json, context),
58
60
  combinator = new Combinator(statement);
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  import ontology from "../ontology";
4
+ import TemporaryContext from "../context/temporary";
4
5
 
5
6
  import { define } from "../ontology";
6
- import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
7
+ import { termsFromJSON, framesFromJSON, statementFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON } from "../utilities/json";
7
8
 
8
9
  export default define(class Conclusion {
9
- constructor(node, string, statement) {
10
+ constructor(context, node, string, statement) {
11
+ this.context = context;
10
12
  this.node = node;
11
13
  this.string = string;
12
14
  this.statement = statement;
13
15
  }
14
16
 
17
+ getContext() {
18
+ return this.context;
19
+ }
20
+
15
21
  getNode() {
16
22
  return this.node;
17
23
  }
@@ -27,6 +33,10 @@ export default define(class Conclusion {
27
33
  verify(context) {
28
34
  let verifies = false;
29
35
 
36
+ const temporaryContext = TemporaryContext.fromNothing(context);
37
+
38
+ context = temporaryContext; ///
39
+
30
40
  const conclusionString = this.string; ///
31
41
 
32
42
  context.trace(`Verifying the '${conclusionString}' conclusion...`, this.node);
@@ -43,35 +53,56 @@ export default define(class Conclusion {
43
53
  }
44
54
 
45
55
  if (verifies) {
56
+ this.context = context;
57
+
46
58
  context.debug(`...verified the '${conclusionString}' conclusion.`, this.node);
47
59
  }
48
60
 
49
61
  return verifies;
50
62
  }
51
63
 
52
- unifyStatement(statement, substitutions, generalContext, specificContext) {
64
+ unifyStatement(statement, substitutions, context) {
53
65
  let statementUnifies;
54
66
 
55
67
  const conclusion = this, ///
56
68
  statementString = statement.getString(),
57
69
  conclusionString = conclusion.getString();
58
70
 
59
- specificContext.trace(`Unifying the '${statementString}' statement with the '${conclusionString}' conclusion...`);
71
+ context.trace(`Unifying the '${statementString}' statement with the '${conclusionString}' conclusion...`);
72
+
73
+ const generalContext = this.context, ///
74
+ specificContext = context; ///
60
75
 
61
76
  statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
62
77
 
63
78
  if (statementUnifies) {
64
- specificContext.debug(`...unified the '${statementString}' statement with the '${conclusionString}' conclusion.`);
79
+ context.debug(`...unified the '${statementString}' statement with the '${conclusionString}' conclusion.`);
65
80
  }
66
81
 
67
82
  return statementUnifies;
68
83
  }
69
84
 
70
85
  toJSON() {
86
+ let frames,
87
+ terms;
88
+
89
+ frames = this.context.getFrames();
90
+
91
+ terms = this.context.getTerms();
92
+
71
93
  const statementJSON = statementToStatementJSON(this.statement),
72
- statement = statementJSON, ///
94
+ framesJSON = framesToFramesJSON(frames),
95
+ termsJSON = termsToTermsJSON(terms);
96
+
97
+ frames = framesJSON; ///
98
+
99
+ terms = termsJSON; ///
100
+
101
+ const statement = statementJSON, ///
73
102
  json = {
74
- statement
103
+ statement,
104
+ frames,
105
+ terms
75
106
  };
76
107
 
77
108
  return json;
@@ -80,10 +111,16 @@ export default define(class Conclusion {
80
111
  static name = "Conclusion";
81
112
 
82
113
  static fromJSON(json, context) {
83
- const statement = statementFromJSON(json, context),
114
+ const terms = termsFromJSON(json, context),
115
+ frames = framesFromJSON(json, context),
116
+ statement = statementFromJSON(json, context),
84
117
  node = null,
85
118
  string = statement.getString(),
86
- conclusion = new Conclusion(node, string, statement);
119
+ temporaryContext = TemporaryContext.fromTermsAndFrames(terms, frames, context);
120
+
121
+ context = temporaryContext; ///
122
+
123
+ const conclusion = new Conclusion(context, node, string, statement);
87
124
 
88
125
  return conclusion;
89
126
  }
@@ -93,7 +130,11 @@ export default define(class Conclusion {
93
130
  node = conclusionNode, ///
94
131
  string = context.nodeAsString(node),
95
132
  statement = Statement.fromConclusionNode(conclusionNode, context),
96
- conclusion = new Conclusion(node, string, statement);
133
+ temporaryContext = null;
134
+
135
+ context = temporaryContext; ///
136
+
137
+ const conclusion = new Conclusion(context, node, string, statement);
97
138
 
98
139
  return conclusion;
99
140
  }
@@ -52,6 +52,8 @@ export default define(class BracketedConstructor extends Constructor {
52
52
  return termUnifies;
53
53
  }
54
54
 
55
+ static name = "BracketedConstructor";
56
+
55
57
  static fromNothing() {
56
58
  const { Term } = ontology,
57
59
  bracketedTermNode = constructorBracketedContext.getBracketedTermNode(),
@@ -67,6 +67,8 @@ export default define(class Constructor {
67
67
  return json;
68
68
  }
69
69
 
70
+ static name = "Constructor";
71
+
70
72
  static fromJSON(json, context) {
71
73
  const term = termFromJSON(json, context),
72
74
  string = stringFromTerm(term),
@@ -5,6 +5,7 @@ import Substitutions from "../substitutions";
5
5
 
6
6
  import { define } from "../ontology";
7
7
  import { unifyStatementIntrinsically } from "../utilities/unification";
8
+ import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
8
9
 
9
10
  export default define(class Declaration {
10
11
  constructor(string, node, statement, metavariable) {
@@ -310,14 +311,46 @@ export default define(class Declaration {
310
311
  }
311
312
 
312
313
  if (metaLemmaMetatheoremUnifies) {
314
+ context = generalContext; ///
315
+
313
316
  context.trace(`...unified the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${declarationString}' declaration...`);
314
317
  }
315
318
 
316
319
  return metaLemmaMetatheoremUnifies;
317
320
  }
318
321
 
322
+ toJSON() {
323
+ let json = null;
324
+
325
+ const simple = this.isSimple();
326
+
327
+ if (simple) {
328
+ const metavariable = this.getMetavariable(),
329
+ metavariableJSON = metavariableToMetavariableJSON(metavariable);
330
+
331
+ json = metavariableJSON; ///
332
+ }
333
+
334
+ return json;
335
+ }
336
+
319
337
  static name = "Declaration";
320
338
 
339
+ static fromJSON(json, context) {
340
+ let declaration = null;
341
+
342
+ if (json !== null) {
343
+ const string = null,
344
+ node = null,
345
+ statement = null,
346
+ metavariable = metavariableFromJSON(json, context);
347
+
348
+ declaration = new Declaration(string, node, statement, metavariable)
349
+ }
350
+
351
+ return declaration;
352
+ }
353
+
321
354
  static fromJudgementNode(judgementNode, context) {
322
355
  const declarationNode = judgementNode.getDeclarationNode(),
323
356
  declaration = declarationFromDeclarationNode(declarationNode, context);
@@ -344,8 +377,8 @@ function declarationFromDeclarationNode(declarationNode, context) {
344
377
  const { Metavariable, Declaration, Statement } = ontology,
345
378
  node = declarationNode, ///
346
379
  string = context.nodeAsString(node),
347
- metavariable = Metavariable.fromDeclarationNode(declarationNode, context),
348
380
  statement = Statement.fromDeclarationNode(declarationNode, context),
381
+ metavariable = Metavariable.fromDeclarationNode(declarationNode, context),
349
382
  declaration = new Declaration(string, node, statement, metavariable);
350
383
 
351
384
  return declaration;
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  import ontology from "../ontology";
4
+ import TemporaryContext from "../context/temporary";
4
5
 
5
6
  import { define } from "../ontology";
6
- import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
7
+ import { termsFromJSON, framesFromJSON, statementFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON } from "../utilities/json";
7
8
 
8
9
  export default define(class Deduction {
9
- constructor(node, string, statement) {
10
+ constructor(context, node, string, statement) {
11
+ this.context = context;
10
12
  this.node = node;
11
13
  this.string = string;
12
14
  this.statement = statement;
13
15
  }
14
16
 
17
+ getContext() {
18
+ return this.context;
19
+ }
20
+
15
21
  getNode(node) {
16
22
  return this.node;
17
23
  }
@@ -27,6 +33,10 @@ export default define(class Deduction {
27
33
  verify(context) {
28
34
  let verifies = false;
29
35
 
36
+ const temporaryContext = TemporaryContext.fromNothing(context);
37
+
38
+ context = temporaryContext; ///
39
+
30
40
  const deductionString = this.string; ///
31
41
 
32
42
  context.trace(`Verifying the '${deductionString}' deduction...`, this.node);
@@ -42,25 +52,30 @@ export default define(class Deduction {
42
52
  }
43
53
 
44
54
  if (verifies) {
55
+ this.context = context;
56
+
45
57
  context.debug(`...verified the '${deductionString}' deduction.`, this.node);
46
58
  }
47
59
 
48
60
  return verifies;
49
61
  }
50
62
 
51
- unifyStatement(statement, substitutions, generalContext, specificContext) {
63
+ unifyStatement(statement, substitutions, context) {
52
64
  let statementUnifies;
53
65
 
54
66
  const deduction = this, ///
55
67
  statementString = statement.getString(),
56
68
  deductionString = deduction.getString();
57
69
 
58
- specificContext.trace(`Unifying the '${statementString}' statement with the '${deductionString}' deduction...`);
70
+ context.trace(`Unifying the '${statementString}' statement with the '${deductionString}' deduction...`);
71
+
72
+ const generalContext = this.context, ///
73
+ specificContext = context; ///
59
74
 
60
75
  statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
61
76
 
62
77
  if (statementUnifies) {
63
- specificContext.debug(`...unified the '${statementString}' statement with the '${deductionString}' deduction.`);
78
+ context.debug(`...unified the '${statementString}' statement with the '${deductionString}' deduction.`);
64
79
  }
65
80
 
66
81
  return statementUnifies;
@@ -89,10 +104,26 @@ export default define(class Deduction {
89
104
  }
90
105
 
91
106
  toJSON() {
107
+ let frames,
108
+ terms;
109
+
110
+ frames = this.context.getFrames();
111
+
112
+ terms = this.context.getTerms();
113
+
92
114
  const statementJSON = statementToStatementJSON(this.statement),
93
- statement = statementJSON, ///
115
+ framesJSON = framesToFramesJSON(frames),
116
+ termsJSON = termsToTermsJSON(terms);
117
+
118
+ frames = framesJSON; ///
119
+
120
+ terms = termsJSON; ///
121
+
122
+ const statement = statementJSON, ///
94
123
  json = {
95
- statement
124
+ statement,
125
+ frames,
126
+ terms
96
127
  };
97
128
 
98
129
  return json;
@@ -101,10 +132,16 @@ export default define(class Deduction {
101
132
  static name = "Deduction";
102
133
 
103
134
  static fromJSON(json, context) {
104
- const statement = statementFromJSON(json, context),
135
+ const terms = termsFromJSON(json, context),
136
+ frames = framesFromJSON(json, context),
137
+ statement = statementFromJSON(json, context),
105
138
  node = null,
106
139
  string = statement.getString(),
107
- deduction = new Deduction(node, string, statement);
140
+ temporaryContext = TemporaryContext.fromTermsAndFrames(terms, frames, context);
141
+
142
+ context = temporaryContext; ///
143
+
144
+ const deduction = new Deduction(context, node, string, statement);
108
145
 
109
146
  return deduction;
110
147
  }
@@ -114,7 +151,11 @@ export default define(class Deduction {
114
151
  node = deductionNode, ///
115
152
  string = context.nodeAsString(node),
116
153
  statement = Statement.fromDeductionNode(deductionNode, context),
117
- deduction = new Deduction(node, string, statement);
154
+ temporaryContext = null;
155
+
156
+ context = temporaryContext; ///
157
+
158
+ const deduction = new Deduction(context, node, string, statement);
118
159
 
119
160
  return deduction;
120
161
  }
@@ -36,14 +36,27 @@ export default define(class Frame {
36
36
 
37
37
  getLength() { return this.declarations.length; }
38
38
 
39
+ getDeclaration() {
40
+ let declaration = null;
41
+
42
+ const length = this.getLength();
43
+
44
+ if (length === 1) {
45
+ const firstDeclaration = first(this.declarations);
46
+
47
+ declaration = firstDeclaration; ///
48
+ }
49
+
50
+ return declaration;
51
+ }
52
+
39
53
  getMetavariable() {
40
54
  let metavariable = null;
41
55
 
42
56
  const simple = this.isSimple();
43
57
 
44
58
  if (simple) {
45
- const firstDeclaration = first(this.declarations),
46
- declaration = firstDeclaration; ///
59
+ const declaration = this.getDeclaration();
47
60
 
48
61
  metavariable = declaration.getMetavariable();
49
62
  }
@@ -54,12 +67,9 @@ export default define(class Frame {
54
67
  isSimple() {
55
68
  let simple = false;
56
69
 
57
- const length = this.getLength();
58
-
59
- if (length === 1) {
60
- const firstDeclaration = first(this.declarations),
61
- declaration = firstDeclaration; ///
70
+ const declaration = this.getDeclaration();
62
71
 
72
+ if (declaration !== null) {
63
73
  simple = declaration.isSimple();
64
74
  }
65
75
 
@@ -73,6 +83,8 @@ export default define(class Frame {
73
83
  return equalTo;
74
84
  }
75
85
 
86
+ matchFrameNode(frameNode) { return this.node.match(frameNode); }
87
+
76
88
  matchSubstitution(substitution, context) {
77
89
  let substitutionMatches = false;
78
90
 
@@ -146,6 +158,10 @@ export default define(class Frame {
146
158
  }
147
159
 
148
160
  if (verifies) {
161
+ const frame = this; ///
162
+
163
+ context.addFrame(frame);
164
+
149
165
  context.debug(`...verified the '${frameString}' frame.`);
150
166
  }
151
167
 
@@ -244,8 +260,42 @@ export default define(class Frame {
244
260
  return verifiesGivenMetaType;
245
261
  }
246
262
 
263
+ toJSON() {
264
+ let json = null;
265
+
266
+ const simple = this.isSimple();
267
+
268
+ if (simple) {
269
+ const declaration = this.getDeclaration(),
270
+ declarationJSON = declaration.toJSON();
271
+
272
+ json = declarationJSON; ///
273
+ }
274
+
275
+ return json;
276
+ }
277
+
247
278
  static name = "Frame";
248
279
 
280
+ static fromJSON(json, context) {
281
+ let frame = null;
282
+
283
+ if (json !== null) {
284
+ const { Declaration } =ontology,
285
+ declaration = Declaration.fromJSON(json, context),
286
+ declarations = [
287
+ declaration
288
+ ],
289
+ string = null,
290
+ node = null,
291
+ tokens = null;
292
+
293
+ frame = new Frame(string, node, tokens, declarations);
294
+ }
295
+
296
+ return frame;
297
+ }
298
+
249
299
  static fromFrameNode(frameNode, context) {
250
300
  let frame = null;
251
301
 
@@ -294,8 +344,7 @@ function frameFromFrameNode(frameNode, context) {
294
344
  string = context.nodeAsString(node),
295
345
  tokens = context.nodeAsTokens(node),
296
346
  declarations = declarationsFromFrameNode(frameNode, context),
297
- metavariables = metavariablesFromFrameNode(frameNode, context),
298
- frame = new Frame(string, node, tokens, declarations, metavariables);
347
+ frame = new Frame(string, node, tokens, declarations);
299
348
 
300
349
  return frame;
301
350
  }
@@ -312,18 +361,6 @@ function declarationsFromFrameNode(frameNode, context) {
312
361
  return declarations;
313
362
  }
314
363
 
315
- function metavariablesFromFrameNode(frameNode, context) {
316
- const { Metavariable } = ontology,
317
- metavariableNodes = frameNode.getMetavariableNodes(),
318
- metavariables = metavariableNodes.map((metavariableNode) => {
319
- const metavariable = Metavariable.fromMetavariableNode(metavariableNode, context);
320
-
321
- return metavariable;
322
- });
323
-
324
- return metavariables;
325
- }
326
-
327
364
  function declarationsStringFromDeclarations(declarations) {
328
365
  const declarationsString = declarations.reduce((declarationsString, declaration) => {
329
366
  const declarationString = declaration.getString();