occam-verify-cli 1.0.448 → 1.0.472

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 (222) hide show
  1. package/lib/constants.js +13 -5
  2. package/lib/context/ephemeral.js +270 -0
  3. package/lib/context/file.js +136 -128
  4. package/lib/context/liminal.js +120 -0
  5. package/lib/context/literal.js +92 -0
  6. package/lib/context/nominal.js +15 -1
  7. package/lib/context/release.js +68 -9
  8. package/lib/context/scoped.js +322 -0
  9. package/lib/context/synthetic.js +133 -0
  10. package/lib/element/assertion/contained.js +66 -66
  11. package/lib/element/assertion/defined.js +32 -32
  12. package/lib/element/assertion/property.js +39 -39
  13. package/lib/element/assertion/satisfies.js +22 -22
  14. package/lib/element/assumption.js +71 -87
  15. package/lib/element/combinator/bracketed.js +1 -10
  16. package/lib/element/conclusion.js +19 -15
  17. package/lib/element/constructor/bracketed.js +1 -10
  18. package/lib/element/constructor.js +2 -2
  19. package/lib/element/declaration/combinator.js +1 -2
  20. package/lib/element/declaration/metavariable.js +3 -3
  21. package/lib/element/declaration/variable.js +3 -3
  22. package/lib/element/deduction.js +26 -20
  23. package/lib/element/derivation.js +3 -3
  24. package/lib/element/equality.js +5 -5
  25. package/lib/element/equivalence.js +112 -107
  26. package/lib/element/equivalences.js +24 -10
  27. package/lib/element/error.js +3 -3
  28. package/lib/element/frame.js +73 -62
  29. package/lib/element/hypothesis.js +2 -2
  30. package/lib/element/judgement.js +40 -60
  31. package/lib/element/metaType.js +4 -4
  32. package/lib/element/metavariable.js +49 -38
  33. package/lib/element/parameter.js +13 -5
  34. package/lib/element/procedureCall.js +16 -16
  35. package/lib/element/proof.js +14 -13
  36. package/lib/element/proofAssertion/premise.js +319 -0
  37. package/lib/element/proofAssertion/step.js +309 -0
  38. package/lib/element/proofAssertion/supposition.js +333 -0
  39. package/lib/element/proofAssertion.js +20 -10
  40. package/lib/element/propertyRelation.js +2 -2
  41. package/lib/element/reference.js +72 -30
  42. package/lib/element/rule.js +26 -28
  43. package/lib/element/section.js +5 -5
  44. package/lib/element/signature.js +9 -6
  45. package/lib/element/statement.js +44 -36
  46. package/lib/element/subproof.js +18 -17
  47. package/lib/element/substitution/frame.js +86 -49
  48. package/lib/element/substitution/reference.js +101 -19
  49. package/lib/element/substitution/statement.js +128 -105
  50. package/lib/element/substitution/term.js +93 -57
  51. package/lib/element/substitution.js +20 -69
  52. package/lib/element/substitutions.js +49 -34
  53. package/lib/element/term.js +41 -30
  54. package/lib/element/topLevelAssertion/axiom.js +331 -0
  55. package/lib/element/{conjecture.js → topLevelAssertion/conjecture.js} +10 -10
  56. package/lib/element/{lemma.js → topLevelAssertion/lemma.js} +9 -9
  57. package/lib/element/{theorem.js → topLevelAssertion/theorem.js} +8 -8
  58. package/lib/element/topLevelAssertion.js +434 -0
  59. package/lib/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +8 -8
  60. package/lib/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +8 -8
  61. package/lib/element/topLevelMetaAssertion.js +293 -0
  62. package/lib/element/type.js +4 -4
  63. package/lib/element/variable.js +48 -40
  64. package/lib/index.js +3 -3
  65. package/lib/main.js +3 -3
  66. package/lib/metaTypes.js +18 -15
  67. package/lib/node/frame.js +2 -2
  68. package/lib/node/metavariable.js +4 -4
  69. package/lib/node/parameter.js +28 -7
  70. package/lib/node/proofAssertion/premise.js +116 -0
  71. package/lib/node/proofAssertion/step.js +152 -0
  72. package/lib/node/proofAssertion/supposition.js +116 -0
  73. package/lib/node/{premise.js → proofAssertion.js} +11 -18
  74. package/lib/node/statement.js +2 -2
  75. package/lib/node/substitution/frame.js +9 -31
  76. package/lib/node/substitution/reference.js +137 -0
  77. package/lib/node/substitution/statement.js +9 -31
  78. package/lib/node/substitution/term.js +9 -23
  79. package/lib/node/{axiom.js → topLevelAssertion/axiom.js} +7 -7
  80. package/lib/node/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
  81. package/lib/node/{lemma.js → topLevelAssertion/lemma.js} +7 -7
  82. package/lib/node/{theorem.js → topLevelAssertion/theorem.js} +7 -7
  83. package/lib/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +9 -9
  84. package/lib/node/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
  85. package/lib/node/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
  86. package/lib/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +9 -9
  87. package/lib/nonTerminalNodeMap.js +15 -14
  88. package/lib/preamble.js +10 -10
  89. package/lib/process/instantiate.js +6 -21
  90. package/lib/process/unify.js +11 -10
  91. package/lib/tokenTypes.js +22 -0
  92. package/lib/types.js +3 -3
  93. package/lib/utilities/bnf.js +5 -5
  94. package/lib/utilities/context.js +63 -0
  95. package/lib/utilities/element.js +235 -408
  96. package/lib/utilities/instance.js +12 -34
  97. package/lib/utilities/json.js +3 -2
  98. package/lib/utilities/string.js +56 -21
  99. package/lib/utilities/unification.js +38 -32
  100. package/lib/utilities/validation.js +47 -50
  101. package/package.json +2 -2
  102. package/src/constants.js +12 -1
  103. package/src/context/ephemeral.js +257 -0
  104. package/src/context/file.js +108 -116
  105. package/src/context/liminal.js +67 -0
  106. package/src/context/literal.js +51 -0
  107. package/src/context/nominal.js +12 -0
  108. package/src/context/release.js +48 -8
  109. package/src/context/{local.js → scoped.js} +43 -125
  110. package/src/context/synthetic.js +60 -0
  111. package/src/element/assertion/contained.js +49 -47
  112. package/src/element/assertion/defined.js +29 -27
  113. package/src/element/assertion/property.js +35 -35
  114. package/src/element/assertion/satisfies.js +19 -18
  115. package/src/element/assumption.js +71 -93
  116. package/src/element/combinator/bracketed.js +0 -7
  117. package/src/element/conclusion.js +25 -24
  118. package/src/element/constructor/bracketed.js +0 -7
  119. package/src/element/constructor.js +1 -1
  120. package/src/element/declaration/combinator.js +0 -1
  121. package/src/element/declaration/metavariable.js +2 -2
  122. package/src/element/declaration/variable.js +5 -5
  123. package/src/element/deduction.js +33 -31
  124. package/src/element/derivation.js +2 -2
  125. package/src/element/equality.js +4 -4
  126. package/src/element/equivalence.js +115 -135
  127. package/src/element/equivalences.js +9 -7
  128. package/src/element/error.js +4 -2
  129. package/src/element/frame.js +80 -65
  130. package/src/element/hypothesis.js +1 -1
  131. package/src/element/judgement.js +42 -62
  132. package/src/element/metaType.js +3 -4
  133. package/src/element/metavariable.js +59 -56
  134. package/src/element/parameter.js +10 -5
  135. package/src/element/procedureCall.js +20 -18
  136. package/src/element/proof.js +14 -16
  137. package/src/element/{premise.js → proofAssertion/premise.js} +57 -53
  138. package/src/element/{step.js → proofAssertion/step.js} +59 -62
  139. package/src/element/{supposition.js → proofAssertion/supposition.js} +67 -56
  140. package/src/element/proofAssertion.js +24 -13
  141. package/src/element/propertyRelation.js +1 -1
  142. package/src/element/reference.js +87 -37
  143. package/src/element/rule.js +31 -37
  144. package/src/element/section.js +5 -5
  145. package/src/element/signature.js +8 -8
  146. package/src/element/statement.js +52 -48
  147. package/src/element/subproof.js +16 -18
  148. package/src/element/substitution/frame.js +104 -50
  149. package/src/element/substitution/reference.js +120 -20
  150. package/src/element/substitution/statement.js +169 -130
  151. package/src/element/substitution/term.js +104 -63
  152. package/src/element/substitution.js +16 -58
  153. package/src/element/substitutions.js +43 -41
  154. package/src/element/term.js +47 -41
  155. package/src/element/{axiom.js → topLevelAssertion/axiom.js} +22 -20
  156. package/src/element/{conjecture.js → topLevelAssertion/conjecture.js} +5 -6
  157. package/src/element/{lemma.js → topLevelAssertion/lemma.js} +5 -6
  158. package/src/element/{theorem.js → topLevelAssertion/theorem.js} +5 -5
  159. package/src/element/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +37 -33
  160. package/src/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +5 -6
  161. package/src/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +5 -6
  162. package/src/element/{metaLemmaMetatheorem.js → topLevelMetaAssertion.js} +19 -17
  163. package/src/element/type.js +2 -4
  164. package/src/element/variable.js +47 -48
  165. package/src/index.js +2 -1
  166. package/src/main.js +2 -1
  167. package/src/metaTypes.js +25 -9
  168. package/src/node/frame.js +1 -1
  169. package/src/node/metavariable.js +3 -3
  170. package/src/node/parameter.js +32 -5
  171. package/src/node/proofAssertion/premise.js +16 -0
  172. package/src/node/{step.js → proofAssertion/step.js} +4 -18
  173. package/src/node/proofAssertion/supposition.js +16 -0
  174. package/src/node/proofAssertion.js +23 -0
  175. package/src/node/statement.js +1 -1
  176. package/src/node/substitution/frame.js +6 -32
  177. package/src/node/substitution/reference.js +38 -0
  178. package/src/node/substitution/statement.js +6 -32
  179. package/src/node/substitution/term.js +6 -22
  180. package/src/node/topLevelAssertion/axiom.js +13 -0
  181. package/src/node/topLevelAssertion/conjecture.js +13 -0
  182. package/src/node/topLevelAssertion/lemma.js +13 -0
  183. package/src/node/topLevelAssertion/theorem.js +13 -0
  184. package/src/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +1 -1
  185. package/src/node/topLevelMetaAssertion/metaLemma.js +13 -0
  186. package/src/node/topLevelMetaAssertion/metatheorem.js +13 -0
  187. package/src/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +1 -1
  188. package/src/nonTerminalNodeMap.js +15 -12
  189. package/src/preamble.js +9 -9
  190. package/src/process/instantiate.js +27 -36
  191. package/src/process/unify.js +10 -9
  192. package/src/tokenTypes.js +4 -0
  193. package/src/types.js +4 -2
  194. package/src/utilities/bnf.js +3 -2
  195. package/src/utilities/context.js +46 -0
  196. package/src/utilities/element.js +302 -509
  197. package/src/utilities/instance.js +19 -42
  198. package/src/utilities/json.js +3 -1
  199. package/src/utilities/string.js +69 -28
  200. package/src/utilities/unification.js +41 -38
  201. package/src/utilities/validation.js +66 -75
  202. package/lib/context/local.js +0 -605
  203. package/lib/context/temporary.js +0 -752
  204. package/lib/element/axiom.js +0 -329
  205. package/lib/element/axiomLemmaTheoremConjecture.js +0 -427
  206. package/lib/element/metaLemmaMetatheorem.js +0 -289
  207. package/lib/element/premise.js +0 -307
  208. package/lib/element/step.js +0 -311
  209. package/lib/element/supposition.js +0 -320
  210. package/lib/log.js +0 -150
  211. package/lib/node/step.js +0 -166
  212. package/lib/node/supposition.js +0 -130
  213. package/src/context/temporary.js +0 -476
  214. package/src/log.js +0 -118
  215. package/src/node/axiom.js +0 -13
  216. package/src/node/conjecture.js +0 -13
  217. package/src/node/lemma.js +0 -13
  218. package/src/node/metaLemma.js +0 -13
  219. package/src/node/metatheorem.js +0 -13
  220. package/src/node/premise.js +0 -30
  221. package/src/node/supposition.js +0 -30
  222. package/src/node/theorem.js +0 -13
@@ -7,7 +7,6 @@ import Element from "../element";
7
7
  import { define } from "../elements";
8
8
  import { unifyStatement } from "../process/unify";
9
9
  import { validateStatements } from "../utilities/validation";
10
- import { instantiateStatement } from "../process/instantiate";
11
10
  import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
12
11
 
13
12
  const { match, backwardsSome } = arrayUtilities;
@@ -17,20 +16,6 @@ export default define(class Statement extends Element {
17
16
  super(context, string, node);
18
17
  }
19
18
 
20
- getMetavariableName() {
21
- let metavariableName = null;
22
-
23
- const singular = this.isSingular();
24
-
25
- if (singular) {
26
- const node = this.getNode();
27
-
28
- metavariableName = node.getMetavariableName();
29
- }
30
-
31
- return metavariableName;
32
- }
33
-
34
19
  isSingular() {
35
20
  const node = this.getNode(),
36
21
  singular = node.isSingular();
@@ -38,6 +23,13 @@ export default define(class Statement extends Element {
38
23
  return singular;
39
24
  }
40
25
 
26
+ getMetavariableName() {
27
+ const node = this.getNode(),
28
+ metavariableName = node.getMetavariableName();
29
+
30
+ return metavariableName;
31
+ }
32
+
41
33
  isTermContained(term, context) {
42
34
  let termContained;
43
35
 
@@ -45,7 +37,7 @@ export default define(class Statement extends Element {
45
37
  termString = term.getString(),
46
38
  statementString = this.getString(); ///
47
39
 
48
- context.trace(`Is the '${termString}' term contained in the '${statementString}' statement...`, node);
40
+ context.trace(`Is the '${termString}' term contained in the '${statementString}' statement...`);
49
41
 
50
42
  const statementNode = node, ///
51
43
  statementNodeTermNodes = statementNode.getTermNodes();
@@ -59,7 +51,7 @@ export default define(class Statement extends Element {
59
51
  });
60
52
 
61
53
  if (termContained) {
62
- context.debug(`...the '${termString}' term is contained in the '${statementString}' statement.`, node);
54
+ context.debug(`...the '${termString}' term is contained in the '${statementString}' statement.`);
63
55
  }
64
56
 
65
57
  return termContained;
@@ -68,13 +60,13 @@ export default define(class Statement extends Element {
68
60
  isFrameContained(frame, context) {
69
61
  let frameContained;
70
62
 
71
- const node = this.getNode(),
72
- frameString = frame.getString(),
63
+ const frameString = frame.getString(),
73
64
  statementString = this.getString(); ///
74
65
 
75
- context.trace(`Is the '${frameString}' frame contained in the '${statementString}' statement...`, node);
66
+ context.trace(`Is the '${frameString}' frame contained in the '${statementString}' statement...`);
76
67
 
77
- const statementNode = node,
68
+ const node = this.getNode(),
69
+ statementNode = node, ///
78
70
  statementNodeFrameNodes = statementNode.getFrameNodes();
79
71
 
80
72
  frameContained = statementNodeFrameNodes.some((statementNodeFrameNode) => { ///
@@ -86,7 +78,7 @@ export default define(class Statement extends Element {
86
78
  });
87
79
 
88
80
  if (frameContained) {
89
- context.debug(`...the '${frameString}' frame is contained in the '${statementString}' statement.`, node);
81
+ context.debug(`...the '${frameString}' frame is contained in the '${statementString}' statement.`);
90
82
  }
91
83
 
92
84
  return frameContained;
@@ -114,13 +106,32 @@ export default define(class Statement extends Element {
114
106
  return metavariableEqualToMetavariable;
115
107
  }
116
108
 
109
+ compareParameter(parameter) {
110
+ let comparesToParamter = false;
111
+
112
+ const singular = this.isSingular();
113
+
114
+ if (singular) {
115
+ const parameterName = parameter.getName();
116
+
117
+ if (parameterName !== null) {
118
+ const metavariableName = this.getMetavariableName();
119
+
120
+ if (parameterName === metavariableName) {
121
+ comparesToParamter = true;
122
+ }
123
+ }
124
+ }
125
+
126
+ return comparesToParamter;
127
+ }
128
+
117
129
  validate(assignments, stated, context) {
118
130
  let validates;
119
131
 
120
- const node = this.getNode(),
121
- statementString = this.getString(); ///
132
+ const statementString = this.getString(); ///
122
133
 
123
- context.trace(`Validating the '${statementString}' statement...`, node);
134
+ context.trace(`Validating the '${statementString}' statement...`);
124
135
 
125
136
  validates = validateStatements.some((validateStatement) => {
126
137
  const statement = this, ///
@@ -136,7 +147,7 @@ export default define(class Statement extends Element {
136
147
 
137
148
  context.addStatement(statement);
138
149
 
139
- context.debug(`...validated the '${statementString}' statement.`, node);
150
+ context.debug(`...validated the '${statementString}' statement.`);
140
151
  }
141
152
 
142
153
  return validates;
@@ -145,11 +156,10 @@ export default define(class Statement extends Element {
145
156
  validateGivenMetaType(metaType, assignments, stated, context) {
146
157
  let validatesGivenMetaType = false;
147
158
 
148
- const node = this.getNode(),
149
- metaTypeString = metaType.getString(),
159
+ const metaTypeString = metaType.getString(),
150
160
  statementString = this.getString(); ///
151
161
 
152
- context.trace(`Validating the '${statementString}' statement given the '${metaTypeString}' meta-type...`, node);
162
+ context.trace(`Validating the '${statementString}' statement given the '${metaTypeString}' meta-type...`);
153
163
 
154
164
  const metaTypeName = metaType.getName();
155
165
 
@@ -160,7 +170,7 @@ export default define(class Statement extends Element {
160
170
  }
161
171
 
162
172
  if (validatesGivenMetaType) {
163
- context.debug(`...validated the '${statementString}' statement given the '${metaTypeString}' meta-type.`, node);
173
+ context.debug(`...validated the '${statementString}' statement given the '${metaTypeString}' meta-type.`);
164
174
  }
165
175
 
166
176
  return validatesGivenMetaType;
@@ -170,13 +180,13 @@ export default define(class Statement extends Element {
170
180
  let subproofUnifies = false;
171
181
 
172
182
  const node = this.getNode(),
173
- context = specificContext, ///
174
- statementNode = node,
183
+ statementNode = node, ///
175
184
  subproofAssertionNode = statementNode.getSubproofAssertionNode(),
176
185
  assertionNode = subproofAssertionNode; ///
177
186
 
178
187
  if (assertionNode !== null) {
179
- const assertion = generalContext.findAssertionByAssertionNode(assertionNode),
188
+ const context = generalContext, ///
189
+ assertion = context.findAssertionByAssertionNode(assertionNode),
180
190
  subproofAssertion = assertion; ///
181
191
 
182
192
  const subproofString = subproof.getString(),
@@ -208,17 +218,18 @@ export default define(class Statement extends Element {
208
218
  unifyStatement(statement, substitutions, generalContext, specificContext) {
209
219
  let statementUnifies;
210
220
 
211
- const generalStatement = this, ///
221
+ const context = specificContext, ///
222
+ generalStatement = this, ///
212
223
  specificStatement = statement, ///
213
224
  generalStatementString = generalStatement.getString(),
214
225
  specificStatementString = specificStatement.getString();
215
226
 
216
- specificContext.trace(`Unifying the '${specificStatementString}' statement with the '${generalStatementString}' statement...`);
227
+ context.trace(`Unifying the '${specificStatementString}' statement with the '${generalStatementString}' statement...`);
217
228
 
218
229
  statementUnifies = unifyStatement(generalStatement, specificStatement, substitutions, generalContext, specificContext);
219
230
 
220
231
  if (statementUnifies) {
221
- specificContext.debug(`...unified the '${specificStatementString}' statement with the '${generalStatementString}' statement.`);
232
+ context.debug(`...unified the '${specificStatementString}' statement with the '${generalStatementString}' statement.`);
222
233
  }
223
234
 
224
235
  return statementUnifies;
@@ -238,8 +249,9 @@ export default define(class Statement extends Element {
238
249
  containedAssertionNode = statementNode.getContainedAssertionNode();
239
250
 
240
251
  if ((definedAssertionNode !== null) || (containedAssertionNode !== null)) {
241
- const assertionNode = (definedAssertionNode || containedAssertionNode),
242
- assertion = generalContext.findAssertionByAssertionNode(assertionNode),
252
+ const context = generalContext, ///
253
+ assertionNode = (definedAssertionNode || containedAssertionNode),
254
+ assertion = context.findAssertionByAssertionNode(assertionNode),
243
255
  assertionUnifiesIndependently = assertion.unifyIndependently(substitutions, generalContext, specificContext);
244
256
 
245
257
  if (assertionUnifiesIndependently) {
@@ -270,7 +282,7 @@ export default define(class Statement extends Element {
270
282
  }
271
283
 
272
284
  toJSON() {
273
- const string = this.getString(),
285
+ const string = this.getString(), ///
274
286
  json = {
275
287
  string
276
288
  };
@@ -281,14 +293,6 @@ export default define(class Statement extends Element {
281
293
  static name = "Statement";
282
294
 
283
295
  static fromJSON(json, context) {
284
- const { string } = json,
285
- statmentNode = instantiateStatement(string, context),
286
- node = statmentNode; ///,
287
-
288
- context = null;
289
-
290
- const statement = new Statement(context, string, node);
291
-
292
- return statement;
296
+ ///
293
297
  }
294
298
  });
@@ -2,8 +2,8 @@
2
2
 
3
3
  import Element from "../element";
4
4
  import elements from "../elements";
5
- import LocalContext from "../context/local";
6
5
 
6
+ import { scope } from "../utilities/context";
7
7
  import { define } from "../elements";
8
8
 
9
9
  export default define(class Subproof extends Element {
@@ -49,25 +49,23 @@ export default define(class Subproof extends Element {
49
49
  verify(substitutions, assignments, context) {
50
50
  let verifies = false;
51
51
 
52
- const localContext = LocalContext.fromNothing(context); ///
52
+ scope(() => {
53
+ const suppositionsVerify = this.suppositions.every((supposition) => {
54
+ const suppositionVerifies = supposition.verify(context);
53
55
 
54
- context = localContext; ///
55
-
56
- const suppositionsVerify = this.suppositions.every((supposition) => {
57
- const suppositionVerifies = supposition.verify(context);
58
-
59
- if (suppositionVerifies) {
60
- return true;
61
- }
62
- });
56
+ if (suppositionVerifies) {
57
+ return true;
58
+ }
59
+ });
63
60
 
64
- if (suppositionsVerify) {
65
- const subDerivationVerifies = this.subDerivation.verify(substitutions, context);
61
+ if (suppositionsVerify) {
62
+ const subDerivationVerifies = this.subDerivation.verify(substitutions, context);
66
63
 
67
- if (subDerivationVerifies) {
68
- verifies = true;
64
+ if (subDerivationVerifies) {
65
+ verifies = true;
66
+ }
69
67
  }
70
- }
68
+ }, context);
71
69
 
72
70
  return verifies;
73
71
  }
@@ -81,7 +79,7 @@ export default define(class Subproof extends Element {
81
79
  unifyWithSatisfiesAssertion(satisfiesAssertion, context) {
82
80
  let unifiesWithSatisfiesAssertion = false;
83
81
 
84
- const subproofString = this.string, ///
82
+ const subproofString = this.getString(), ///
85
83
  satisfiesAssertionString = satisfiesAssertion.getString();
86
84
 
87
85
  context.trace(`Unifying the '${subproofString}' subproof with the '${satisfiesAssertionString}' satisfies assertion...`)
@@ -95,7 +93,7 @@ export default define(class Subproof extends Element {
95
93
  if (axiomSatisfiable) {
96
94
  const { Substitutions } = elements,
97
95
  subproof = this, ///
98
- substitutions = Substitutions.fromNothing(),
96
+ substitutions = Substitutions.fromNothing(context),
99
97
  statementUnifies = axiom.unifySubproof(subproof, substitutions, context);
100
98
 
101
99
  if (statementUnifies) {
@@ -3,77 +3,134 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { literally } from "../../utilities/context";
6
7
  import { instantiateFrameSubstitution } from "../../process/instantiate";
7
- import { frameSubstitutionFromFrameSubstitutionNode, frameSubstitutionFromStatementNode } from "../../utilities/element";
8
+ import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
9
+ import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
8
10
 
9
11
  export default define(class FrameSubstitution extends Substitution {
10
- constructor(context, string, node, frame, metavariable) {
12
+ constructor(context, string, node, targetFrame, replacementFrame) {
11
13
  super(context, string, node);
12
14
 
13
- this.frame = frame;
14
- this.metavariable = metavariable;
15
+ this.targetFrame = targetFrame;
16
+ this.replacementFrame = replacementFrame;
15
17
  }
16
18
 
17
- getFrame() {
18
- return this.frame;
19
+ getTargetFrame() {
20
+ return this.targetFrame;
19
21
  }
20
22
 
21
- getMetavariable() {
22
- return this.metavariable;
23
+ getReplacementFrame() {
24
+ return this.replacementFrame;
25
+ }
26
+
27
+ getTargetNode() {
28
+ const targetFrameNode = this.targetFrame.getNode(),
29
+ tergetNode = targetFrameNode; ///
30
+
31
+ return tergetNode;
23
32
  }
24
33
 
25
34
  getReplacementNode() {
26
- const frameNode = this.frame.getNode(),
27
- replacementNode = frameNode; ///
35
+ const replacementFrameNode = this.replacementFrame.getNode(),
36
+ replacementNode = replacementFrameNode; ///
28
37
 
29
38
  return replacementNode;
30
39
  }
31
40
 
32
- isFrameEqualToFrame(frame) { return this.frame.isEqualTo(frame); }
41
+ isTrivial() {
42
+ const targetFrameEqualToReplacementFrame = this.targetFrame.isEqualTo(this.replacementFrame),
43
+ trivial = targetFrameEqualToReplacementFrame; ///
44
+
45
+ return trivial;
46
+ }
33
47
 
34
- isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
48
+ compareFrame(frame, context) {
49
+ const frameEqualToReplacementFrame = this.replacementFrame.isEqualTo(frame),
50
+ comparedToFrame = frameEqualToReplacementFrame; ///
35
51
 
36
- verify(context) {
37
- let verifies = false;
52
+ return comparedToFrame;
53
+ }
54
+
55
+ compareParameter(parameter) {
56
+ const targetFrameComparesToParameter = this.targetFrame.compareParameter(parameter),
57
+ comparesToParameter = targetFrameComparesToParameter; ///
58
+
59
+ return comparesToParameter;
60
+ }
38
61
 
39
- const frameSubstitutionString = this.string; ///
62
+ validate(context) {
63
+ let validates = false;
40
64
 
41
- context.trace(`Verifiying the '${frameSubstitutionString}' frame substitution...`);
65
+ const frameSubstitutionString = this.getString(); ///
42
66
 
43
- const frameSingular = this.frame.isSingular();
67
+ context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
44
68
 
45
- if (frameSingular) {
46
- if (this.metavariable !== null) {
47
- const metavariablePresent = context.isMetavariablePresent(this.metavariable);
69
+ const targetFrameValidates = this.validateTargetFrame(context);
48
70
 
49
- if (metavariablePresent) {
50
- const frameMetavariable = this.frame.getMetavariable(),
51
- frameMetavariablePresent = context.isMetavariablePresent(frameMetavariable);
71
+ if (targetFrameValidates) {
72
+ const replacementFrameValidates = this.validateReplacementFrame(context);
52
73
 
53
- if (frameMetavariablePresent) {
54
- verifies = true;
55
- } else {
56
- context.debug(`The '${frameSubstitutionString}' frame substitution's general frame's metavariable is not present.`);
57
- }
58
- } else {
59
- context.debug(`The '${frameSubstitutionString}' frame substitution's specific frame's metavariable is not present.`);
60
- }
61
- } else {
62
- context.debug(`The '${frameSubstitutionString}' frame substitution's general frame is not singular.`);
74
+ if (replacementFrameValidates) {
75
+ validates = true;
63
76
  }
64
- } else {
65
- context.debug(`The '${frameSubstitutionString}' frame substitution's specific frame is not singular.`);
66
77
  }
67
78
 
68
- if (verifies) {
79
+ if (validates) {
69
80
  const substititoin = this; ///
70
81
 
71
82
  context.addSubstitution(substititoin);
72
83
 
73
- context.debug(`...verified the '${frameSubstitutionString}' frame substitution.`);
84
+ context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
74
85
  }
75
86
 
76
- return verifies;
87
+ return validates;
88
+ }
89
+
90
+ validateTargetFrame(context) {
91
+ let targetFrameValidates = false;
92
+
93
+ const targetFrameString = this.targetFrame.getString(),
94
+ frameSubstitutionString = this.getString(); ///
95
+
96
+ context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${targetFrameString}' target frame...`);
97
+
98
+ const targetFrameSingular = this.targetFrame.isSingular();
99
+
100
+ if (targetFrameSingular) {
101
+ const stated = true,
102
+ assignments = null;
103
+
104
+ targetFrameValidates = this.targetFrame.validate(assignments, stated, context);
105
+ } else {
106
+ context.debug(`The '${frameSubstitutionString}' frame subtitution's '${targetFrameString}' target frame is not singular.`);
107
+ }
108
+
109
+ if (targetFrameValidates) {
110
+ context.debug(`...validated the '${frameSubstitutionString}' frame subtitution's '${targetFrameString}' target frame...`);
111
+ }
112
+
113
+ return targetFrameValidates;
114
+ }
115
+
116
+ validateReplacementFrame(context) {
117
+ let replacementFrameValidates;
118
+
119
+ const replacementFrameString = this.replacementFrame.getString(),
120
+ frameSubstitutionString = this.getString(); ///
121
+
122
+ context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${replacementFrameString}' replacement frame...`);
123
+
124
+ const stated = true,
125
+ assignments = null;
126
+
127
+ replacementFrameValidates = this.replacementFrame.validate(assignments, stated, context);
128
+
129
+ if (replacementFrameValidates) {
130
+ context.debug(`...validated the '${frameSubstitutionString}' frame subtitution's '${replacementFrameString}' replacement frame...`);
131
+ }
132
+
133
+ return replacementFrameValidates;
77
134
  }
78
135
 
79
136
  static name = "FrameSubstitution";
@@ -86,18 +143,15 @@ export default define(class FrameSubstitution extends Substitution {
86
143
  }
87
144
 
88
145
  static fromFrameAndMetavariable(frame, metavariable, context) {
89
- const string = stringFromFrameAndMetavariable(frame, metavariable),
90
- frameSubstitutionNode = instantiateFrameSubstitution(string, context),
91
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
146
+ return literally((context) => {
147
+ const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
148
+ string = frameSubstitutionString, ///
149
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context),
150
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
92
151
 
93
- return frameSubstitution;
152
+ frameSubstitution.validate(context);
153
+
154
+ return frameSubstitution;
155
+ }, context);
94
156
  }
95
157
  });
96
-
97
- function stringFromFrameAndMetavariable(frame, metavariable) {
98
- const frameString = frame.getString(),
99
- metavariableString = metavariable.getString(),
100
- string = `[${frameString} for [${metavariableString}]]`;
101
-
102
- return string;
103
- }
@@ -3,42 +3,142 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { literally } from "../../utilities/context";
6
7
  import { instantiateReferenceSubstitution } from "../../process/instantiate";
7
8
  import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
9
+ import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
8
10
 
9
11
  export default define(class ReferenceSubstitution extends Substitution {
10
- constructor(context, string, node, reference, metavariable) {
12
+ constructor(context, string, node, targetReference, replacementReference) {
11
13
  super(context, string, node);
12
14
 
13
- this.reference = reference;
14
- this.metavariable = metavariable;
15
+ this.targetReference = targetReference;
16
+ this.replacementReference = replacementReference;
15
17
  }
16
18
 
17
- getReference() {
18
- return this.reference;
19
+ getTargetReference() {
20
+ return this.targetReference;
19
21
  }
20
22
 
21
- getMetavariable() {
22
- return this.metavariable;
23
+ getReplacementReference() {
24
+ return this.replacementReference;
23
25
  }
24
26
 
25
- isReferenceEqualToReference(reference) { return this.reference.isEqualTo(reference); }
27
+ getTargetNode() {
28
+ const targetReferenceNode = this.targetReference.getNode(),
29
+ tergetNode = targetReferenceNode; ///
30
+
31
+ return tergetNode;
32
+ }
33
+
34
+ getReplacementNode() {
35
+ const replacementReferenceNode = this.replacementReference.getNode(),
36
+ replacementNode = replacementReferenceNode; ///
37
+
38
+ return replacementNode;
39
+ }
40
+
41
+ isTrivial() {
42
+ const targetReferenceEqualToReplacementReference = this.targetReference.isEqualTo(this.replacementReference),
43
+ trivial = targetReferenceEqualToReplacementReference; ///
44
+
45
+ return trivial;
46
+ }
47
+
48
+ compareReference(reference, context) {
49
+ const referenceEqualToReplacementReference = this.replacementReference.isEqualTo(reference),
50
+ comparedToReference = referenceEqualToReplacementReference; ///
51
+
52
+ return comparedToReference;
53
+ }
54
+
55
+ compareParameter(parameter) {
56
+ const targetReferenceComparesToParameter = this.targetReference.compareParameter(parameter),
57
+ comparesToParameter = targetReferenceComparesToParameter; ///
58
+
59
+ return comparesToParameter;
60
+ }
61
+
62
+ validate(context) {
63
+ let validates = false;
64
+
65
+ const referenceSubstitutionString = this.getString(); ///
66
+
67
+ context.trace(`Validating the '${referenceSubstitutionString}' reference substitution...`);
68
+
69
+ const targetReferenceValidates = this.validateTargetReference(context);
70
+
71
+ if (targetReferenceValidates) {
72
+ const replacementReferenceValidates = this.validateReplacementReference(context);
73
+
74
+ if (replacementReferenceValidates) {
75
+ validates = true;
76
+ }
77
+ }
78
+
79
+ if (validates) {
80
+ const substititoin = this; ///
81
+
82
+ context.addSubstitution(substititoin);
83
+
84
+ context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
85
+ }
86
+
87
+ return validates;
88
+ }
89
+
90
+ validateTargetReference(context) {
91
+ let targetReferenceValidates = false;
92
+
93
+ const targetReferenceString = this.targetReference.getString(),
94
+ referenceSubstitutionString = this.getString(); ///
95
+
96
+ context.trace(`Validating the '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference...`);
97
+
98
+ const targetReferenceSingular = this.targetReference.isSingular();
99
+
100
+ if (targetReferenceSingular) {
101
+ targetReferenceValidates = this.targetReference.validate(context);
102
+ } else {
103
+ context.debug(`The '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference is not singular.`);
104
+ }
105
+
106
+ if (targetReferenceValidates) {
107
+ context.debug(`...validated the '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference...`);
108
+ }
109
+
110
+ return targetReferenceValidates;
111
+ }
112
+
113
+ validateReplacementReference(context) {
114
+ let replacementReferenceValidates;
115
+
116
+ const replacementReferenceString = this.replacementReference.getString(),
117
+ referenceSubstitutionString = this.getString(); ///
118
+
119
+ context.trace(`Validating the '${referenceSubstitutionString}' reference subtitution's '${replacementReferenceString}' replacement reference...`);
120
+
121
+ replacementReferenceValidates = this.replacementReference.validate(context);
122
+
123
+ if (replacementReferenceValidates) {
124
+ context.debug(`...validated the '${referenceSubstitutionString}' reference subtitution's '${replacementReferenceString}' replacement reference...`);
125
+ }
126
+
127
+ return replacementReferenceValidates;
128
+ }
26
129
 
27
130
  static name = "ReferenceSubstitution";
28
131
 
29
132
  static fromReferenceAndMetavariable(reference, metavariable, context) {
30
- const string = stringFromReferenceAndMetavariable(reference, metavariable),
31
- referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
32
- referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
133
+ return literally((context) => {
134
+ const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
135
+ string = referenceSubstitutionString, ///
136
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
137
+ referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
138
+
139
+ referenceSubstitution.validate(context);
33
140
 
34
- return referenceSubstitution;
141
+ return referenceSubstitution;
142
+ }, context);
35
143
  }
36
144
  });
37
-
38
- function stringFromReferenceAndMetavariable(reference, metavariable) {
39
- const referenceString = reference.getString(),
40
- metavariableString = metavariable.getString(),
41
- string = `[${referenceString} for ${metavariableString}]`;
42
-
43
- return string;
44
- }