occam-verify-cli 1.0.388 → 1.0.404

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 (305) hide show
  1. package/lib/action/verify.js +3 -3
  2. package/lib/assignment/equality.js +2 -2
  3. package/lib/context/file.js +11 -11
  4. package/lib/context/local.js +38 -61
  5. package/lib/context/partial.js +10 -10
  6. package/lib/context/temporary.js +755 -0
  7. package/lib/mixins/statement/verify.js +38 -16
  8. package/lib/mixins/step/unify.js +7 -8
  9. package/lib/node/argument.js +4 -4
  10. package/lib/node/assertion/contained.js +6 -6
  11. package/lib/node/assertion/defined.js +6 -6
  12. package/lib/node/assertion/property.js +6 -6
  13. package/lib/node/assertion/satisfies.js +6 -6
  14. package/lib/node/assertion/subproof.js +6 -6
  15. package/lib/node/assertion/type.js +6 -6
  16. package/lib/node/assertion.js +107 -0
  17. package/lib/node/assumption.js +134 -0
  18. package/lib/node/axiom.js +6 -6
  19. package/lib/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +12 -12
  20. package/lib/node/body.js +4 -5
  21. package/lib/node/combinator.js +4 -4
  22. package/lib/node/conclusion.js +4 -4
  23. package/lib/node/conjecture.js +6 -6
  24. package/lib/node/constructor.js +4 -4
  25. package/lib/node/declaration/combinator.js +6 -6
  26. package/lib/node/declaration/complexType.js +6 -6
  27. package/lib/node/declaration/constructor.js +6 -6
  28. package/lib/node/declaration/metavariable.js +6 -6
  29. package/lib/node/declaration/property.js +6 -6
  30. package/lib/node/declaration/simpleType.js +6 -6
  31. package/lib/node/declaration/typePrefix.js +6 -6
  32. package/lib/node/declaration/variable.js +6 -6
  33. package/lib/node/declaration.js +6 -22
  34. package/lib/node/deduction.js +4 -4
  35. package/lib/node/derivation.js +4 -4
  36. package/lib/node/document.js +107 -0
  37. package/lib/node/equality.js +4 -4
  38. package/lib/node/error.js +4 -4
  39. package/lib/node/frame.js +25 -14
  40. package/lib/node/header.js +4 -4
  41. package/lib/node/hypothesis.js +4 -4
  42. package/lib/node/judgement.js +8 -8
  43. package/lib/node/label.js +4 -4
  44. package/lib/node/labels.js +4 -4
  45. package/lib/node/lemma.js +6 -6
  46. package/lib/node/metaArgument.js +4 -4
  47. package/lib/node/metaLemma.js +6 -6
  48. package/lib/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +12 -12
  49. package/lib/node/metaType.js +4 -4
  50. package/lib/node/metatheorem.js +6 -6
  51. package/lib/node/metavariable.js +4 -4
  52. package/lib/node/nonsense.js +4 -4
  53. package/lib/node/parameter.js +4 -4
  54. package/lib/node/parenthesisedLabel.js +4 -4
  55. package/lib/node/parenthesisedLabels.js +4 -4
  56. package/lib/node/placeholder.js +107 -0
  57. package/lib/node/premise.js +4 -4
  58. package/lib/node/procedureCall.js +4 -4
  59. package/lib/node/procedureReference.js +4 -4
  60. package/lib/node/proof.js +4 -4
  61. package/lib/node/property.js +4 -4
  62. package/lib/node/propertyRelation.js +4 -4
  63. package/lib/node/qualification.js +4 -4
  64. package/lib/node/reference.js +4 -4
  65. package/lib/node/rule.js +4 -4
  66. package/lib/node/section.js +4 -4
  67. package/lib/node/signature.js +4 -4
  68. package/lib/node/statement.js +15 -4
  69. package/lib/node/step.js +4 -4
  70. package/lib/node/subDerivation.js +4 -4
  71. package/lib/node/subproof.js +4 -4
  72. package/lib/node/substitution/frame.js +28 -6
  73. package/lib/node/substitution/statement.js +6 -6
  74. package/lib/node/substitution/term.js +28 -6
  75. package/lib/node/substitution.js +107 -0
  76. package/lib/node/supposition.js +4 -4
  77. package/lib/node/term.js +27 -4
  78. package/lib/node/theorem.js +6 -6
  79. package/lib/node/type.js +4 -4
  80. package/lib/node/typePrefix.js +4 -4
  81. package/lib/node/types.js +4 -4
  82. package/lib/node/variable.js +4 -4
  83. package/lib/nominal/parser.js +3 -3
  84. package/lib/nonTerminalNode.js +222 -0
  85. package/lib/nonTerminalNodeMap.js +5 -3
  86. package/lib/ontology/assertion/contained.js +80 -39
  87. package/lib/ontology/assertion/defined.js +80 -39
  88. package/lib/ontology/assertion/property.js +71 -29
  89. package/lib/ontology/assertion/satisfies.js +73 -25
  90. package/lib/ontology/assertion/subproof.js +95 -41
  91. package/lib/ontology/assertion/type.js +74 -18
  92. package/lib/ontology/assertion.js +66 -0
  93. package/lib/ontology/assumption.js +379 -0
  94. package/lib/ontology/axiom.js +8 -11
  95. package/lib/ontology/combinator/bracketed.js +17 -3
  96. package/lib/ontology/combinator.js +17 -3
  97. package/lib/ontology/conclusion.js +38 -9
  98. package/lib/ontology/constructor/bracketed.js +17 -3
  99. package/lib/ontology/constructor.js +17 -3
  100. package/lib/ontology/declaration/combinator.js +75 -33
  101. package/lib/ontology/declaration/complexType.js +110 -63
  102. package/lib/ontology/declaration/constructor.js +81 -38
  103. package/lib/ontology/declaration/metavariable.js +87 -39
  104. package/lib/ontology/declaration/simpleType.js +95 -48
  105. package/lib/ontology/declaration/typePrefix.js +87 -40
  106. package/lib/ontology/declaration/variable.js +87 -39
  107. package/lib/ontology/declaration.js +13 -313
  108. package/lib/ontology/deduction.js +38 -9
  109. package/lib/ontology/equivalence.js +295 -0
  110. package/lib/ontology/equivalences.js +264 -0
  111. package/lib/ontology/frame.js +83 -51
  112. package/lib/ontology/hypothesis.js +11 -11
  113. package/lib/ontology/judgement.js +8 -8
  114. package/lib/ontology/label.js +5 -6
  115. package/lib/ontology/metavariable.js +14 -15
  116. package/lib/ontology/premise.js +60 -21
  117. package/lib/ontology/procedureCall.js +15 -15
  118. package/lib/ontology/procedureReference.js +1 -1
  119. package/lib/ontology/proof.js +2 -2
  120. package/lib/ontology/reference.js +6 -13
  121. package/lib/ontology/rule.js +69 -71
  122. package/lib/ontology/section.js +2 -2
  123. package/lib/ontology/signature.js +2 -2
  124. package/lib/ontology/statement.js +36 -24
  125. package/lib/ontology/step.js +38 -26
  126. package/lib/ontology/subproof.js +12 -13
  127. package/lib/ontology/substitution/frame.js +69 -21
  128. package/lib/ontology/substitution/reference.js +24 -9
  129. package/lib/ontology/substitution/statement.js +137 -76
  130. package/lib/ontology/substitution/term.js +75 -35
  131. package/lib/ontology/substitution.js +50 -44
  132. package/lib/ontology/substitutions.js +425 -0
  133. package/lib/ontology/supposition.js +69 -29
  134. package/lib/ontology/term.js +35 -37
  135. package/lib/ontology/topLevelAssertion.js +16 -17
  136. package/lib/ontology/topLevelMetaAssertion.js +3 -4
  137. package/lib/ontology/variable.js +9 -14
  138. package/lib/preamble.js +7 -4
  139. package/lib/ruleNames.js +20 -12
  140. package/lib/unifier/intrinsicLevel.js +4 -5
  141. package/lib/unifier/metaLevel.js +24 -24
  142. package/lib/utilities/brackets.js +4 -21
  143. package/lib/utilities/context.js +6 -6
  144. package/lib/utilities/frame.js +18 -0
  145. package/lib/utilities/json.js +24 -1
  146. package/lib/utilities/metavariable.js +18 -0
  147. package/lib/utilities/statement.js +18 -0
  148. package/lib/utilities/substitutions.js +43 -30
  149. package/lib/utilities/unification.js +10 -16
  150. package/lib/utilities/variable.js +18 -0
  151. package/package.json +10 -10
  152. package/src/action/verify.js +2 -2
  153. package/src/assignment/equality.js +1 -1
  154. package/src/context/file.js +13 -11
  155. package/src/context/local.js +40 -65
  156. package/src/context/partial.js +9 -14
  157. package/src/context/temporary.js +463 -0
  158. package/src/mixins/statement/verify.js +60 -23
  159. package/src/mixins/step/unify.js +6 -6
  160. package/src/node/argument.js +1 -1
  161. package/src/node/assertion/contained.js +3 -3
  162. package/src/node/assertion/defined.js +3 -3
  163. package/src/node/assertion/property.js +3 -3
  164. package/src/node/assertion/satisfies.js +3 -3
  165. package/src/node/assertion/subproof.js +3 -3
  166. package/src/node/assertion/type.js +3 -3
  167. package/src/node/assertion.js +7 -0
  168. package/src/node/assumption.js +35 -0
  169. package/src/node/axiom.js +3 -3
  170. package/src/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +2 -2
  171. package/src/node/body.js +1 -3
  172. package/src/node/combinator.js +1 -1
  173. package/src/node/conclusion.js +1 -1
  174. package/src/node/conjecture.js +3 -3
  175. package/src/node/constructor.js +1 -1
  176. package/src/node/declaration/combinator.js +3 -3
  177. package/src/node/declaration/complexType.js +3 -3
  178. package/src/node/declaration/constructor.js +3 -3
  179. package/src/node/declaration/metavariable.js +3 -3
  180. package/src/node/declaration/property.js +3 -3
  181. package/src/node/declaration/simpleType.js +3 -3
  182. package/src/node/declaration/typePrefix.js +3 -3
  183. package/src/node/declaration/variable.js +3 -3
  184. package/src/node/declaration.js +2 -18
  185. package/src/node/deduction.js +1 -1
  186. package/src/node/derivation.js +1 -1
  187. package/src/node/document.js +7 -0
  188. package/src/node/equality.js +1 -1
  189. package/src/node/error.js +1 -1
  190. package/src/node/frame.js +23 -11
  191. package/src/node/header.js +1 -1
  192. package/src/node/hypothesis.js +1 -1
  193. package/src/node/judgement.js +6 -6
  194. package/src/node/label.js +1 -1
  195. package/src/node/labels.js +1 -1
  196. package/src/node/lemma.js +3 -3
  197. package/src/node/metaArgument.js +1 -1
  198. package/src/node/metaLemma.js +3 -3
  199. package/src/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +2 -2
  200. package/src/node/metaType.js +1 -1
  201. package/src/node/metatheorem.js +3 -3
  202. package/src/node/metavariable.js +1 -1
  203. package/src/node/nonsense.js +1 -1
  204. package/src/node/parameter.js +1 -1
  205. package/src/node/parenthesisedLabel.js +1 -1
  206. package/src/node/parenthesisedLabels.js +1 -1
  207. package/src/node/placeholder.js +7 -0
  208. package/src/node/premise.js +1 -1
  209. package/src/node/procedureCall.js +1 -1
  210. package/src/node/procedureReference.js +1 -1
  211. package/src/node/proof.js +1 -1
  212. package/src/node/property.js +1 -1
  213. package/src/node/propertyRelation.js +1 -1
  214. package/src/node/qualification.js +1 -1
  215. package/src/node/reference.js +1 -1
  216. package/src/node/rule.js +2 -2
  217. package/src/node/section.js +1 -1
  218. package/src/node/signature.js +1 -1
  219. package/src/node/statement.js +13 -1
  220. package/src/node/step.js +1 -1
  221. package/src/node/subDerivation.js +1 -1
  222. package/src/node/subproof.js +1 -1
  223. package/src/node/substitution/frame.js +29 -3
  224. package/src/node/substitution/statement.js +3 -3
  225. package/src/node/substitution/term.js +29 -3
  226. package/src/node/substitution.js +7 -0
  227. package/src/node/supposition.js +1 -1
  228. package/src/node/term.js +27 -1
  229. package/src/node/theorem.js +3 -3
  230. package/src/node/type.js +1 -1
  231. package/src/node/typePrefix.js +1 -1
  232. package/src/node/types.js +1 -1
  233. package/src/node/variable.js +1 -1
  234. package/src/nominal/parser.js +2 -2
  235. package/src/{node/nonTerminal.js → nonTerminalNode.js} +31 -25
  236. package/src/nonTerminalNodeMap.js +10 -5
  237. package/src/ontology/assertion/contained.js +21 -32
  238. package/src/ontology/assertion/defined.js +20 -31
  239. package/src/ontology/assertion/property.js +7 -20
  240. package/src/ontology/assertion/satisfies.js +8 -16
  241. package/src/ontology/assertion/subproof.js +36 -42
  242. package/src/ontology/assertion/type.js +10 -11
  243. package/src/ontology/assertion.js +23 -0
  244. package/src/ontology/assumption.js +385 -0
  245. package/src/ontology/axiom.js +7 -16
  246. package/src/ontology/combinator/bracketed.js +2 -0
  247. package/src/ontology/combinator.js +2 -0
  248. package/src/ontology/conclusion.js +51 -10
  249. package/src/ontology/constructor/bracketed.js +2 -0
  250. package/src/ontology/constructor.js +2 -0
  251. package/src/ontology/declaration/combinator.js +15 -24
  252. package/src/ontology/declaration/complexType.js +57 -53
  253. package/src/ontology/declaration/constructor.js +25 -31
  254. package/src/ontology/declaration/metavariable.js +25 -30
  255. package/src/ontology/declaration/simpleType.js +34 -38
  256. package/src/ontology/declaration/typePrefix.js +23 -31
  257. package/src/ontology/declaration/variable.js +26 -31
  258. package/src/ontology/declaration.js +8 -339
  259. package/src/ontology/deduction.js +51 -10
  260. package/src/{equivalence.js → ontology/equivalence.js} +4 -3
  261. package/src/{equivalences.js → ontology/equivalences.js} +14 -12
  262. package/src/ontology/frame.js +93 -66
  263. package/src/ontology/hypothesis.js +8 -8
  264. package/src/ontology/judgement.js +8 -8
  265. package/src/ontology/label.js +2 -7
  266. package/src/ontology/metavariable.js +14 -17
  267. package/src/ontology/premise.js +82 -25
  268. package/src/ontology/procedureCall.js +14 -14
  269. package/src/ontology/procedureReference.js +2 -2
  270. package/src/ontology/proof.js +1 -1
  271. package/src/ontology/reference.js +5 -9
  272. package/src/ontology/rule.js +79 -82
  273. package/src/ontology/section.js +1 -1
  274. package/src/ontology/signature.js +1 -1
  275. package/src/ontology/statement.js +37 -27
  276. package/src/ontology/step.js +45 -28
  277. package/src/ontology/subproof.js +10 -10
  278. package/src/ontology/substitution/frame.js +72 -26
  279. package/src/ontology/substitution/reference.js +8 -6
  280. package/src/ontology/substitution/statement.js +95 -76
  281. package/src/ontology/substitution/term.js +81 -41
  282. package/src/ontology/substitution.js +35 -34
  283. package/src/{substitutions.js → ontology/substitutions.js} +29 -28
  284. package/src/ontology/supposition.js +88 -28
  285. package/src/ontology/term.js +31 -43
  286. package/src/ontology/topLevelAssertion.js +16 -18
  287. package/src/ontology/topLevelMetaAssertion.js +3 -3
  288. package/src/ontology/variable.js +10 -17
  289. package/src/preamble.js +6 -3
  290. package/src/ruleNames.js +10 -8
  291. package/src/unifier/intrinsicLevel.js +5 -6
  292. package/src/unifier/metaLevel.js +32 -29
  293. package/src/utilities/brackets.js +3 -29
  294. package/src/utilities/context.js +5 -5
  295. package/src/utilities/frame.js +13 -0
  296. package/src/utilities/json.js +28 -0
  297. package/src/utilities/metavariable.js +13 -0
  298. package/src/utilities/statement.js +13 -0
  299. package/src/utilities/substitutions.js +59 -33
  300. package/src/utilities/unification.js +8 -24
  301. package/src/utilities/variable.js +13 -0
  302. package/lib/equivalence.js +0 -294
  303. package/lib/equivalences.js +0 -263
  304. package/lib/node/nonTerminal.js +0 -218
  305. package/lib/substitutions.js +0 -424
@@ -2,11 +2,12 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import { EMPTY_STRING } from "./constants";
5
+ import { define } from "../ontology";
6
+ import { EMPTY_STRING } from "../constants";
6
7
 
7
8
  const { find, first, clear, prune, filter, compress, correlate } = arrayUtilities;
8
9
 
9
- export default class Substitutions {
10
+ export default define(class Substitutions {
10
11
  constructor(array, savedArray) {
11
12
  this.array = array;
12
13
  this.savedArray = savedArray;
@@ -22,18 +23,6 @@ export default class Substitutions {
22
23
 
23
24
  getLength() { return this.array.length; }
24
25
 
25
- getFirstSubstitution() {
26
- let firstSubstitution = null;
27
-
28
- const length = this.getLength();
29
-
30
- if (length > 0) {
31
- firstSubstitution = first(this.array);
32
- }
33
-
34
- return firstSubstitution;
35
- }
36
-
37
26
  getMetavariables() {
38
27
  const metavariables = [];
39
28
 
@@ -70,6 +59,18 @@ export default class Substitutions {
70
59
  return nonTrivialLength;
71
60
  }
72
61
 
62
+ getFirstSubstitution() {
63
+ let firstSubstitution = null;
64
+
65
+ const length = this.getLength();
66
+
67
+ if (length > 0) {
68
+ firstSubstitution = first(this.array);
69
+ }
70
+
71
+ return firstSubstitution;
72
+ }
73
+
73
74
  mapSubstitution(callback) { return this.array.map(callback); }
74
75
 
75
76
  findSubstitution(callback) { return this.array.find(callback) || null; } ///
@@ -107,7 +108,7 @@ export default class Substitutions {
107
108
 
108
109
  findSubstitutionsByMetavariable(metavariable) {
109
110
  const substitutions = this.findSubstitutions((substitution) => {
110
- const substitutionMetavariableEqualToMetavariable = substitution.isMetavariableEqualTo(metavariable);
111
+ const substitutionMetavariableEqualToMetavariable = substitution.isMetavariableEqualToMetavariable(metavariable);
111
112
 
112
113
  if (substitutionMetavariableEqualToMetavariable) {
113
114
  return true;
@@ -123,7 +124,7 @@ export default class Substitutions {
123
124
 
124
125
  if (substitutionSimple) {
125
126
  const simpleSubstitution = substitution, ///
126
- simpleSubstitutionMetavariableEqualToMetavariable = simpleSubstitution.isMetavariableEqualTo(metavariable);
127
+ simpleSubstitutionMetavariableEqualToMetavariable = simpleSubstitution.isMetavariableEqualToMetavariable(metavariable);
127
128
 
128
129
  if (simpleSubstitutionMetavariableEqualToMetavariable) {
129
130
  return true;
@@ -140,7 +141,7 @@ export default class Substitutions {
140
141
 
141
142
  if (substitutionComplex) {
142
143
  const complexSubstitution = substitution, ///
143
- complexSubstitutionMetavariableEqualToMetavariable = complexSubstitution.isMetavariableEqualTo(metavariable);
144
+ complexSubstitutionMetavariableEqualToMetavariable = complexSubstitution.isMetavariableEqualToMetavariable(metavariable);
144
145
 
145
146
  if (complexSubstitutionMetavariableEqualToMetavariable) {
146
147
  return true;
@@ -155,11 +156,11 @@ export default class Substitutions {
155
156
  const substitutionA = substitution; ///
156
157
 
157
158
  substitution = this.findSubstitution((substitution) => { ///
158
- const substitutionMetavariableEqualToMetavariable = substitution.isMetavariableEqualTo(metavariable);
159
+ const substitutionMetavariableEqualToMetavariable = substitution.isMetavariableEqualToMetavariable(metavariable);
159
160
 
160
161
  if (substitutionMetavariableEqualToMetavariable) {
161
162
  const substitutionB = substitution, ///
162
- substitutionBSubstitutionEqualToSubstitutionA = substitutionB.isSubstitutionEqualTo(substitutionA);
163
+ substitutionBSubstitutionEqualToSubstitutionA = substitutionB.isSubstitutionEqualToSubstitution(substitutionA);
163
164
 
164
165
  if (substitutionBSubstitutionEqualToSubstitutionA) {
165
166
  return true;
@@ -192,15 +193,15 @@ export default class Substitutions {
192
193
  return substitutionPresent;
193
194
  }
194
195
 
195
- addSubstitution(substitution, specificContext) {
196
+ addSubstitution(substitution, context) {
196
197
  this.array.push(substitution);
197
198
 
198
199
  const substitutionString = substitution.getString();
199
200
 
200
- specificContext.trace(`Added the ${substitutionString} substitution.`);
201
+ context.trace(`Added the ${substitutionString} substitution.`);
201
202
  }
202
203
 
203
- removeSubstitution(substitution, specificContext) {
204
+ removeSubstitution(substitution, context) {
204
205
  const substitutionA = substitution; ///
205
206
 
206
207
  prune(this.array, (substitution) => {
@@ -213,7 +214,7 @@ export default class Substitutions {
213
214
 
214
215
  const substitutionString = substitution.getString();
215
216
 
216
- specificContext.trace(`Removed the ${substitutionString} substitution.`);
217
+ context.trace(`Removed the ${substitutionString} substitution.`);
217
218
  }
218
219
 
219
220
  correlateSubstitutions(substitutions) {
@@ -247,7 +248,7 @@ export default class Substitutions {
247
248
  this.savedArray = null;
248
249
  }
249
250
 
250
- resolve(generalContext, specificContext) {
251
+ resolve(context) {
251
252
  const metavariables = this.getMetavariables();
252
253
 
253
254
  metavariables.forEach((metavariable) => {
@@ -261,7 +262,7 @@ export default class Substitutions {
261
262
  resolved = substitution.isResolved();
262
263
 
263
264
  if (!resolved) {
264
- substitution.resolve(substitutions, generalContext, specificContext);
265
+ substitution.resolve(substitutions, context);
265
266
  }
266
267
  });
267
268
 
@@ -297,7 +298,7 @@ export default class Substitutions {
297
298
  ];
298
299
  }
299
300
 
300
- rollback(specificContext) {
301
+ rollback(context) {
301
302
  const array = [
302
303
  ...this.array
303
304
  ];
@@ -305,7 +306,7 @@ export default class Substitutions {
305
306
  leftDifference(array, this.savedArray);
306
307
 
307
308
  array.forEach((substitution) => {
308
- this.removeSubstitution(substitution, specificContext);
309
+ this.removeSubstitution(substitution, context);
309
310
  });
310
311
 
311
312
  this.array = [
@@ -357,7 +358,7 @@ export default class Substitutions {
357
358
 
358
359
  return substitutions;
359
360
  }
360
- }
361
+ });
361
362
 
362
363
  function leftDifference(arrayA, arrayB) {
363
364
  filter(arrayA, (elementA) => {
@@ -1,20 +1,26 @@
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
7
  import { assignAssignments } from "../utilities/assignments";
7
8
  import { subproofAssertionFromStatement } from "../utilities/context";
8
- import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
9
+ import { termsFromJSON, framesFromJSON, statementFromJSON, procedureCallFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
9
10
 
10
11
  export default define(class Supposition {
11
- constructor(node, string, statement, procedureCall) {
12
+ constructor(context, node, string, statement, procedureCall) {
13
+ this.context = context;
12
14
  this.node = node;
13
15
  this.string = string;
14
16
  this.statement = statement;
15
17
  this.procedureCall = procedureCall;
16
18
  }
17
19
 
20
+ getContext() {
21
+ return this.context;
22
+ }
23
+
18
24
  getNode() {
19
25
  return this.node;
20
26
  }
@@ -34,6 +40,10 @@ export default define(class Supposition {
34
40
  verify(context) {
35
41
  let verifies = false;
36
42
 
43
+ const temporaryContext = TemporaryContext.fromNothing(context);
44
+
45
+ context = temporaryContext; ///
46
+
37
47
  const suppositionString = this.string; ///
38
48
 
39
49
  context.trace(`Verifying the '${suppositionString}' supposition...`, this.node);
@@ -71,6 +81,8 @@ export default define(class Supposition {
71
81
  }
72
82
 
73
83
  if (verifies) {
84
+ this.context = context;
85
+
74
86
  context.debug(`...verified the '${suppositionString}' supposition.`, this.node);
75
87
  }
76
88
 
@@ -100,24 +112,38 @@ export default define(class Supposition {
100
112
  }
101
113
 
102
114
  unifyIndependently(substitutions, context) {
103
- let unifiesIndependently;
115
+ let unifiesIndependently = false;
116
+
117
+ const suppositionString = this.string, ///
118
+ generalContext = this.context, ///
119
+ specificContext = context; ///
120
+
121
+ context.trace(`Unifying the '${suppositionString}' supposition independently...`, this.node);
104
122
 
105
123
  if (this.statement !== null) {
106
- const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, context);
124
+ const statementUnifiesIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
107
125
 
108
- unifiesIndependently = statementResolvedIndependently; ///
126
+ if (statementUnifiesIndependently) {
127
+ unifiesIndependently = true;
128
+ }
109
129
  }
110
130
 
111
131
  if (this.procedureCall !== null) {
112
132
  const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, context);
113
133
 
114
- unifiesIndependently = procedureCallResolvedIndependently; ///
134
+ if (procedureCallResolvedIndependently) {
135
+ unifiesIndependently = true;
136
+ }
137
+ }
138
+
139
+ if (unifiesIndependently) {
140
+ context.debug(`...unified the '${suppositionString}' supposition independenly.`, this.node);
115
141
  }
116
142
 
117
143
  return unifiesIndependently;
118
144
  }
119
145
 
120
- unifyStepOrSubproof(stepOrSubproof, substitutions, generalContext, specificContext) {
146
+ unifyStepOrSubproof(stepOrSubproof, substitutions, context) {
121
147
  let stepOrSubproofUnifies = false;
122
148
 
123
149
  const stepOrSubProofStep = stepOrSubproof.isStep(),
@@ -131,40 +157,42 @@ export default define(class Supposition {
131
157
  substitutions.snapshot();
132
158
 
133
159
  if (subproof !== null) {
134
- const subproofUnifies = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
160
+ const subproofUnifies = this.unifySubproof(subproof, substitutions, context);
135
161
 
136
162
  stepOrSubproofUnifies = subproofUnifies; ///
137
163
  }
138
164
 
139
165
  if (step !== null) {
140
- const statementUnifies = this.unifyStep(step, substitutions, generalContext, specificContext);
166
+ const statementUnifies = this.unifyStep(step, substitutions, context);
141
167
 
142
168
  stepOrSubproofUnifies = statementUnifies; ///
143
169
  }
144
170
 
145
171
  if (stepOrSubproofUnifies) {
146
- substitutions.resolve(generalContext, specificContext);
172
+ substitutions.resolve(context);
147
173
  }
148
174
 
149
175
  stepOrSubproofUnifies ?
150
176
  substitutions.continue() :
151
- substitutions.rollback(specificContext);
177
+ substitutions.rollback(context);
152
178
 
153
179
  return stepOrSubproofUnifies;
154
180
  }
155
181
 
156
- unifyStep(step, substitutions, generalContext, specificContext) {
182
+ unifyStep(step, substitutions, context) {
157
183
  let stepUnifies;
158
184
 
185
+ context = step.getContext();
186
+
159
187
  const statement = step.getStatement(),
160
- statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
188
+ statementUnifies = this.unifyStatement(statement, substitutions, context);
161
189
 
162
190
  stepUnifies = statementUnifies; ///
163
191
 
164
192
  return stepUnifies;
165
193
  }
166
194
 
167
- unifySubproof(subproof, substitutions, generalContext, specificContext) {
195
+ unifySubproof(subproof, substitutions, context) {
168
196
  let subproofUnifies = false;
169
197
 
170
198
  const supposition = this, ///
@@ -172,52 +200,74 @@ export default define(class Supposition {
172
200
  suppositionStatement = supposition.getStatement(),
173
201
  suppositionStatementString = suppositionStatement.getString();
174
202
 
175
- specificContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
203
+ context.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
176
204
 
177
205
  if (this.statement !== null) {
178
206
  const context = generalContext, ///
179
207
  subproofAssertion = subproofAssertionFromStatement(this.statement, context);
180
208
 
181
209
  if (subproofAssertion !== null) {
210
+ const generalContext = this.context, ///
211
+ specificContext = context; ///
212
+
182
213
  subproofUnifies = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
183
214
  }
184
215
  }
185
216
 
186
217
  if (subproofUnifies) {
187
- specificContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
218
+ context.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
188
219
  }
189
220
 
190
221
  return subproofUnifies;
191
222
  }
192
223
 
193
- unifyStatement(statement, substitutions, generalContext, specificContext) {
224
+ unifyStatement(statement, substitutions, context) {
194
225
  let statementUnifies;
195
226
 
196
227
  const supposition = this, ///
197
228
  statementString = statement.getString(),
198
229
  suppositionString = supposition.getString();
199
230
 
200
- specificContext.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
231
+ context.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
201
232
 
202
233
  if (this.statement !== null) {
234
+ const generalContext = this.context, ///
235
+ specificContext = context; ///
236
+
203
237
  statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
204
238
  }
205
239
 
206
240
  if (statementUnifies) {
207
- specificContext.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
241
+ context.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
208
242
  }
209
243
 
210
244
  return statementUnifies;
211
245
  }
212
246
 
213
247
  toJSON() {
214
- const statementJSON = statementToStatementJSON(this.statement),
215
- procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
248
+ let frames,
249
+ terms;
250
+
251
+ frames = this.context.getFrames();
252
+
253
+ terms = this.context.getTerms();
254
+
255
+ const procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
256
+ statementJSON = statementToStatementJSON(this.statement),
257
+ framesJSON = framesToFramesJSON(frames),
258
+ termsJSON = termsToTermsJSON(terms);
259
+
260
+ frames = framesJSON; ///
261
+
262
+ terms = termsJSON; ///
263
+
264
+ const procedureCall = procedureCallJSON, ///
216
265
  statement = statementJSON, ///
217
- procedureCall = procedureCallJSON, ///
218
266
  json = {
267
+ procedureCall,
219
268
  statement,
220
- procedureCall
269
+ frames,
270
+ terms
221
271
  };
222
272
 
223
273
  return json;
@@ -226,8 +276,11 @@ export default define(class Supposition {
226
276
  static name = "Supposition";
227
277
 
228
278
  static fromJSON(json, context) {
229
- const statement = statementFromJSON(json, context),
230
- procedureCall = procedureCallFromJSON(json, context);
279
+ const terms = termsFromJSON(json, context),
280
+ frames = framesFromJSON(json, context),
281
+ statement = statementFromJSON(json, context),
282
+ procedureCall = procedureCallFromJSON(json, context),
283
+ temporaryContext = TemporaryContext.fromTermsAndFrames(terms, frames, context);
231
284
 
232
285
  let string;
233
286
 
@@ -239,8 +292,11 @@ export default define(class Supposition {
239
292
  string = procedureCall.getString();
240
293
  }
241
294
 
242
- const node = null,
243
- supposition = new Supposition(node, string, statement, procedureCall);
295
+ const node = null;
296
+
297
+ context = temporaryContext; ///
298
+
299
+ const supposition = new Supposition(context, node, string, statement, procedureCall);
244
300
 
245
301
  return supposition;
246
302
  }
@@ -251,7 +307,11 @@ export default define(class Supposition {
251
307
  string = context.nodeAsString(node),
252
308
  statement = Statement.fromSuppositionNode(suppositionNode, context),
253
309
  procedureCall = ProcedureCall.fromSuppositionNode(suppositionNode, context),
254
- supposition = new Supposition(node, string, statement, procedureCall);
310
+ temporaryContext = null;
311
+
312
+ context = temporaryContext; ///
313
+
314
+ const supposition = new Supposition(context, node, string, statement, procedureCall);
255
315
 
256
316
  return supposition
257
317
  }
@@ -35,40 +35,9 @@ export default define(class Term {
35
35
  this.type = type;
36
36
  }
37
37
 
38
- getVariable(context) {
39
- const { Variable } = ontology,
40
- termNode = this.node, ///
41
- variable = Variable.fromTermNode(termNode, context);
38
+ matchTermNode(termNode) { return this.node.match(termNode); }
42
39
 
43
- return variable;
44
- }
45
-
46
- getVariables(context) {
47
- const termNode = this.node,
48
- variableNodes = termNode.getVariableNodes(),
49
- variables = variableNodes.map((variableNode) => {
50
- const { Variable } = ontology,
51
- variable = Variable.fromVariableNode(variableNode, context);
52
-
53
- return variable;
54
- });
55
-
56
- compress(variables, (variableA, variableB) => {
57
- const variableAEqualToVariableB = variableA.isEqualTo(variableB);
58
-
59
- if (variableAEqualToVariableB) {
60
- return true;
61
- }
62
- });
63
-
64
- return variables;
65
- }
66
-
67
- matchTermNode(termNode) {
68
- const termNodeMatches = this.node.match(termNode);
69
-
70
- return termNodeMatches;
71
- }
40
+ isSimple() { return this.node.isSimple();}
72
41
 
73
42
  isProvisional() { return this.type.isProvisional(); }
74
43
 
@@ -79,16 +48,9 @@ export default define(class Term {
79
48
  return equalTo;
80
49
  }
81
50
 
82
- isSimple() {
83
- const termNode = this.node,
84
- singularVariableNode = termNode.getSingularVariableNode(),
85
- simple = (singularVariableNode !== null);
86
-
87
- return simple;
88
- }
89
-
90
51
  isGrounded(definedVariables, context) {
91
- const variables = this.getVariables(context);
52
+ const term = this, ///
53
+ variables = variablesFromTerm(term, context);
92
54
 
93
55
  filter(variables, (variable) => {
94
56
  const definedVariablesIncludesVariable = definedVariables.includes(variable);
@@ -106,7 +68,8 @@ export default define(class Term {
106
68
  }
107
69
 
108
70
  isInitiallyGrounded(context) {
109
- const variables = this.getVariables(context),
71
+ const term = this, ///
72
+ variables = variablesFromTerm(term, context),
110
73
  variablesLength = variables.length,
111
74
  initiallyGrounded = (variablesLength === 0);
112
75
 
@@ -137,6 +100,10 @@ export default define(class Term {
137
100
  });
138
101
 
139
102
  if (verifies) {
103
+ const term = this; ///
104
+
105
+ context.addTerm(term);
106
+
140
107
  context.debug(`...verified the '${termString}' term.`);
141
108
  }
142
109
 
@@ -274,3 +241,24 @@ export default define(class Term {
274
241
  }
275
242
  });
276
243
 
244
+ export function variablesFromTerm(term, context) {
245
+ const termNode = term.getNode(),
246
+ variableNodes = termNode.getVariableNodes(),
247
+ variables = variableNodes.map((variableNode) => {
248
+ const variableIdentifier = variableNode.getVariableIdentifier(),
249
+ variable = context.findVariableByVariableIdentifier(variableIdentifier);
250
+
251
+ return variable;
252
+ });
253
+
254
+ compress(variables, (variableA, variableB) => {
255
+ const variableAEqualToVariableB = variableA.isEqualTo(variableB);
256
+
257
+ if (variableAEqualToVariableB) {
258
+ return true;
259
+ }
260
+ });
261
+
262
+ return variables;
263
+ }
264
+
@@ -4,7 +4,6 @@ import { arrayUtilities } from "necessary";
4
4
 
5
5
  import ontology from "../ontology";
6
6
  import LocalContext from "../context/local";
7
- import Substitutions from "../substitutions";
8
7
 
9
8
  import { labelsFromJSON,
10
9
  deductionFromJSON,
@@ -112,7 +111,7 @@ export default class TopLevelAssertion {
112
111
  const labelsVerify = this.verifyLabels();
113
112
 
114
113
  if (labelsVerify) {
115
- const localContext = LocalContext.fromContext(this.context),
114
+ const localContext = LocalContext.fromNothing(this.context),
116
115
  context = localContext, ///
117
116
  suppositionsVerify = this.verifySuppositions(context);
118
117
 
@@ -175,7 +174,8 @@ export default class TopLevelAssertion {
175
174
  if (this.proof === null) {
176
175
  proofVerifies = true;
177
176
  } else {
178
- const substitutions = Substitutions.fromNothing();
177
+ const { Substitutions } = ontology,
178
+ substitutions = Substitutions.fromNothing();
179
179
 
180
180
  proofVerifies = this.proof.verify(substitutions, this.deduction, context);
181
181
  }
@@ -212,10 +212,10 @@ export default class TopLevelAssertion {
212
212
  return hypothesesCorrelate;
213
213
  }
214
214
 
215
- unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext) {
215
+ unifyStatementWithDeduction(statement, substitutions, context) {
216
216
  let statementUnifiesWithDeduction = false;
217
217
 
218
- const statementUnifies = this.deduction.unifyStatement(statement, substitutions, generalContext, specificContext); ///
218
+ const statementUnifies = this.deduction.unifyStatement(statement, substitutions, context); ///
219
219
 
220
220
  if (statementUnifies) {
221
221
  statementUnifiesWithDeduction = true;
@@ -225,39 +225,37 @@ export default class TopLevelAssertion {
225
225
  }
226
226
 
227
227
  unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context) {
228
- let statementAndStepsOrSubproofsUnify = false;
228
+ let statementAndStepsOrSubproofsUnifies = false;
229
229
 
230
230
  const hypothesesCorrelate = this.correlateHypotheses(context);
231
231
 
232
232
  if (hypothesesCorrelate) {
233
- const generalContext = this.context, ///
234
- specificContext = context, ///
235
- statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
233
+ const statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, context);
236
234
 
237
235
  if (statementUnifiesWithDeduction) {
238
- const stepsOrSubproofsUnifyWithSuppositions = this.unifyStepsOrSubproofsWithSuppositions(stepsOrSubproofs, substitutions, generalContext, specificContext);
236
+ const stepsOrSubproofsUnifyWithSuppositions = this.unifyStepsOrSubproofsWithSuppositions(stepsOrSubproofs, substitutions, context);
239
237
 
240
238
  if (stepsOrSubproofsUnifyWithSuppositions) {
241
239
  const substitutionsResolved = substitutions.areResolved();
242
240
 
243
241
  if (substitutionsResolved) {
244
- statementAndStepsOrSubproofsUnify = true;
242
+ statementAndStepsOrSubproofsUnifies = true;
245
243
  }
246
244
  }
247
245
  }
248
246
  }
249
247
 
250
- return statementAndStepsOrSubproofsUnify;
248
+ return statementAndStepsOrSubproofsUnifies;
251
249
  }
252
250
 
253
251
  unifyStepsOrSubproofsWithSupposition(stepsOrSubproofs, supposition, substitutions, generalContext, specificContext) {
254
- let stepsOrSubproofsUnifyWithSupposition = false;
252
+ let stepsOrSubproofsUnifiesWithSupposition = false;
255
253
 
256
254
  const context = specificContext, ///
257
255
  suppositionUnifiesIndependently = supposition.unifyIndependently(substitutions, context);
258
256
 
259
257
  if (suppositionUnifiesIndependently) {
260
- stepsOrSubproofsUnifyWithSupposition = true;
258
+ stepsOrSubproofsUnifiesWithSupposition = true;
261
259
  } else {
262
260
  const stepOrSubproof = extract(stepsOrSubproofs, (stepOrSubproof) => {
263
261
  const stepOrSubproofUnifies = supposition.unifyStepOrSubproof(stepOrSubproof, substitutions, generalContext, specificContext);
@@ -268,20 +266,20 @@ export default class TopLevelAssertion {
268
266
  }) || null;
269
267
 
270
268
  if (stepOrSubproof !== null) {
271
- stepsOrSubproofsUnifyWithSupposition = true;
269
+ stepsOrSubproofsUnifiesWithSupposition = true;
272
270
  }
273
271
  }
274
272
 
275
- return stepsOrSubproofsUnifyWithSupposition;
273
+ return stepsOrSubproofsUnifiesWithSupposition;
276
274
  }
277
275
 
278
276
  unifyStepsOrSubproofsWithSuppositions(stepsOrSubproofs, substitutions, generalContext, specificContext) {
279
277
  stepsOrSubproofs = reverse(stepsOrSubproofs); ///
280
278
 
281
279
  const stepsOrSubproofsUnifyWithSuppositions = backwardsEvery(this.suppositions, (supposition) => {
282
- const stepsOrSubproofsUnifyWithSupposition = this.unifyStepsOrSubproofsWithSupposition(stepsOrSubproofs, supposition, substitutions, generalContext, specificContext);
280
+ const stepsOrSubproofsUnifiesWithSupposition = this.unifyStepsOrSubproofsWithSupposition(stepsOrSubproofs, supposition, substitutions, generalContext, specificContext);
283
281
 
284
- if (stepsOrSubproofsUnifyWithSupposition) {
282
+ if (stepsOrSubproofsUnifiesWithSupposition) {
285
283
  return true;
286
284
  }
287
285
  });
@@ -2,7 +2,6 @@
2
2
 
3
3
  import ontology from "../ontology";
4
4
  import LocalContext from "../context/local";
5
- import Substitutions from "../substitutions";
6
5
 
7
6
  import { proofFromProofNode, deductionFromDeductionNode, suppositionsFromSuppositionNodes } from "./topLevelAssertion";
8
7
  import { labelFromJSON,
@@ -73,7 +72,7 @@ export default class TopLevelMetaAssertion {
73
72
  const labelVerifies = this.verifyLabel();
74
73
 
75
74
  if (labelVerifies) {
76
- const localContext = LocalContext.fromContext(this.context),
75
+ const localContext = LocalContext.fromNothing(this.context),
77
76
  context = localContext, ///
78
77
  suppositionsVerify = this.verifySuppositions(context);
79
78
 
@@ -169,7 +168,8 @@ export default class TopLevelMetaAssertion {
169
168
  }
170
169
 
171
170
  static fromNode(Class, node, context) {
172
- const topLevelAssertionNode = node, ///
171
+ const { Substitutions } = ontology,
172
+ topLevelAssertionNode = node, ///
173
173
  proofNode = topLevelAssertionNode.getProofNode(),
174
174
  labelNode = topLevelAssertionNode.getLabelNode(),
175
175
  deductionNode = topLevelAssertionNode.getDeductionNode(),