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
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+
3
+ import ontology from "../ontology";
4
+
5
+ import { define } from "../ontology";
6
+ import { unifyStatementIntrinsically } from "../utilities/unification";
7
+ import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
8
+
9
+ export default define(class Assumption {
10
+ constructor(string, node, statement, metavariable) {
11
+ this.string = string;
12
+ this.node = node;
13
+ this.statement = statement;
14
+ this.metavariable = metavariable;
15
+ }
16
+
17
+ getString() {
18
+ return this.string;
19
+ }
20
+
21
+ getNode() {
22
+ return this.node;
23
+ }
24
+
25
+ getStatement() {
26
+ return this.statement;
27
+ }
28
+
29
+ getMetavariable() {
30
+ return this.metavariable;
31
+ }
32
+
33
+ isSimple() {
34
+ const simple = (this.statement === null);
35
+
36
+ return simple;
37
+ }
38
+
39
+ matchSubstitution(substitution, context) {
40
+ let substitutionMatches = false;
41
+
42
+ const assumptionString = this.string, ///
43
+ substitutionString = substitution.getString();
44
+
45
+ context.trace(`Matching the '${substitutionString}' substitution against the '${assumptionString}' assumption...`);
46
+
47
+ const simple = this.isSimple();
48
+
49
+ if (simple) {
50
+ const judgement = context.findJudgementByMetavariable(this.metavariable);
51
+
52
+ if (judgement !== null) {
53
+ const assumption = judgement.getDeclaration();
54
+
55
+ substitutionMatches = assumption.matchSubstitution(substitution, context);
56
+ }
57
+ } else {
58
+ const statement = substitution.getStatement(),
59
+ metavariable = substitution.getMetavariable(),
60
+ statementEqualToStatement = this.statement.isEqualTo(statement),
61
+ metavariableEqualToMetavariable = this.metavariable.isEqualTo(metavariable);
62
+
63
+ if (metavariableEqualToMetavariable && statementEqualToStatement) {
64
+ substitutionMatches = true;
65
+ }
66
+ }
67
+
68
+ if (substitutionMatches) {
69
+ context.debug(`...matches the '${assumptionString}' substitution against the '${substitutionString}' assumption.`);
70
+ }
71
+
72
+ return substitutionMatches;
73
+ }
74
+
75
+ verify(assignments, stated, context) {
76
+ let verifies = false;
77
+
78
+ const assumptionString = this.string; ///
79
+
80
+ context.trace(`Verifying the '${assumptionString}' assumption...`);
81
+
82
+ const simple = this.isSimple();
83
+
84
+ if (simple) {
85
+ const verifiesAsMetavariable = this.verifyAsMetavariable(assignments, stated, context);
86
+
87
+ verifies = verifiesAsMetavariable; ///
88
+ } else {
89
+ const metavariableVerifiesAsReference = this.verifyMetavariableAsReference(assignments, stated, context);
90
+
91
+ if (metavariableVerifiesAsReference) {
92
+ const statementVerifies = this.verifyStatement(assignments, stated, context);
93
+
94
+ if (statementVerifies) {
95
+ let verifiesWhenStated = false,
96
+ verifiesWhenDerived = false;
97
+
98
+ if (stated) {
99
+ verifiesWhenStated = this.verifyWhenStated(assignments, context);
100
+ } else {
101
+ verifiesWhenDerived = this.verifyWhenDerived(context);
102
+ }
103
+
104
+ if (verifiesWhenStated || verifiesWhenDerived) {
105
+ verifies = true;
106
+ }
107
+ }
108
+ }
109
+
110
+ if (verifies) {
111
+ context.debug(`...verified the '${assumptionString}' assumption.`);
112
+ }
113
+ }
114
+
115
+ return verifies;
116
+ }
117
+
118
+ verifyMetavariableAsReference(assignments, stated, context) {
119
+ let metavariableVerifiesAsReference;
120
+
121
+ const assumptionString = this.string,
122
+ metavariableString = this.metavariable.getString();
123
+
124
+ context.trace(`Verifying the '${assumptionString}' assumption's '${metavariableString}' metavariable as a reference...`);
125
+
126
+ const reference = referenceFromMetavariable(this.metavariable, context),
127
+ referenceVerifies = reference.verify(context);
128
+
129
+ metavariableVerifiesAsReference = referenceVerifies; ///
130
+
131
+ if (metavariableVerifiesAsReference) {
132
+ context.debug(`...verified the '${assumptionString}' assumption's '${metavariableString}' metavariable as a reference.`);
133
+ }
134
+
135
+ return metavariableVerifiesAsReference;
136
+ }
137
+
138
+ verifyStatement(assignments, stated, context) {
139
+ let statementVerifies;
140
+
141
+ if (this.statement === null) {
142
+ statementVerifies = true;
143
+ } else {
144
+ const statementString = this.statement.getString();
145
+
146
+ context.trace(`Verifying the '${statementString}' statement...`);
147
+
148
+ stated = true; ///
149
+
150
+ assignments = null; ///
151
+
152
+ statementVerifies = this.statement.verify(assignments, stated, context);
153
+
154
+ if (statementVerifies) {
155
+ context.debug(`...verified the '${statementString}' statement.`);
156
+ }
157
+ }
158
+
159
+ return statementVerifies;
160
+ }
161
+
162
+ verifyAsMetavariable(assignments, stated, context) {
163
+ let verifiesAsMetavariable;
164
+
165
+ const assumptionString = this.string, ///
166
+ metavariableString = this.metavariable.getString();
167
+
168
+ context.trace(`Verifying the '${assumptionString}' assumption's '${metavariableString}' metavariable...`);
169
+
170
+ verifiesAsMetavariable = this.metavariable.verify(context);
171
+
172
+ if (verifiesAsMetavariable) {
173
+ context.debug(`...verified the '${assumptionString}' assumption's '${metavariableString}' metavariable.`);
174
+ }
175
+
176
+ return verifiesAsMetavariable;
177
+ }
178
+
179
+ verifyWhenStated(assignments, context) {
180
+ let verifiesWhenStated;
181
+
182
+ const assumptionString = this.string; ///
183
+
184
+ context.trace(`Verifying the '${assumptionString}' stated assumption...`);
185
+
186
+ const reference = referenceFromMetavariable(this.metavariable, context),
187
+ metavariablePresent = context.isMetavariablePresentByReference(reference);
188
+
189
+ if (metavariablePresent) {
190
+ verifiesWhenStated = true;
191
+ } else {
192
+ const metaLemmaMetatheorems = context.findMetaLemmaMetatheoremsByReference(reference),
193
+ metaLemmaMetatheoremsUnify = metaLemmaMetatheorems.every((metaLemmaMetatheorem) => {
194
+ const metaLemmaMetatheoremUnifies = this.unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context);
195
+
196
+ if (metaLemmaMetatheoremUnifies) {
197
+ return true;
198
+ }
199
+ });
200
+
201
+ verifiesWhenStated = metaLemmaMetatheoremsUnify; ///
202
+ }
203
+
204
+ if (verifiesWhenStated) {
205
+ context.debug(`...verified the '${assumptionString}' stated assumption.`);
206
+ }
207
+
208
+ return verifiesWhenStated;
209
+ }
210
+
211
+ verifyWhenDerived(context) {
212
+ let verifiesWhenDerived;
213
+
214
+ const assumptionString = this.string; ///
215
+
216
+ context.trace(`Verifying the '${assumptionString}' derived assumption...`);
217
+
218
+ const reference = referenceFromMetavariable(this.metavariable, context),
219
+ metaLemmaMetatheoremPresent = context.isMetaLemmaMetatheoremPresentByReference(reference);
220
+
221
+ verifiesWhenDerived = metaLemmaMetatheoremPresent; ///
222
+
223
+ if (verifiesWhenDerived) {
224
+ context.debug(`...verified the '${assumptionString}' derived assumption.`);
225
+ }
226
+
227
+ return verifiesWhenDerived;
228
+ }
229
+
230
+ unifyStatement(statement, substitutions, generalContext, specificContext) {
231
+ let statementUnifies;
232
+
233
+ const simple = this.isSimple();
234
+
235
+ if (simple) {
236
+ statementUnifies = false;
237
+ } else {
238
+ const context = generalContext, ///
239
+ statementString = statement.getString(),
240
+ assumptionStatementString = this.statement.getString();
241
+
242
+ context.trace(`Unifying the '${statementString}' statement with the '${assumptionStatementString}' statement...`);
243
+
244
+ const generalStatement = this.statement,
245
+ specificStatement = statement, ///
246
+ statementUUnifiesIntrinsically = unifyStatementIntrinsically(generalStatement, specificStatement, substitutions, generalContext, specificContext);
247
+
248
+ statementUnifies = statementUUnifiesIntrinsically; ///
249
+
250
+ if (statementUnifies) {
251
+ context.debug(`...unified the '${statementString}' statement with the '${assumptionStatementString}' statement.`);
252
+ }
253
+ }
254
+
255
+ return statementUnifies;
256
+ }
257
+
258
+ unifyLabel(label, substitutions, generalContext, specificContext) {
259
+ let labelUnifiesWithReference;
260
+
261
+ const context = generalContext, ///
262
+ labelString = label.getString(),
263
+ assumptionString = this.string; //;/
264
+
265
+ context.trace(`Unifying the '${labelString}' label with the '${assumptionString}' assumption...`);
266
+
267
+ const reference = referenceFromMetavariable(this.metavariable, context),
268
+ labelUnifies = reference.unifyLabel(label, substitutions, context);
269
+
270
+ labelUnifiesWithReference = labelUnifies; ///
271
+
272
+ if (labelUnifiesWithReference) {
273
+ context.debug(`...unified the '${labelString}' label with the '${assumptionString}' assumption.`);
274
+ }
275
+
276
+ return labelUnifiesWithReference;
277
+ }
278
+
279
+ unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context) {
280
+ let metaLemmaMetatheoremUnifies = false;
281
+
282
+ const assumptionString = this.string, ///
283
+ metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
284
+
285
+ context.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${assumptionString}' assumption...`);
286
+
287
+ const generalContext = context; ///
288
+
289
+ context = metaLemmaMetatheorem.getContext(); ///
290
+
291
+ const { Substitutions } = ontology,
292
+ specificContext = context, ///
293
+ labelSubstitutions = Substitutions.fromNothing(),
294
+ label = metaLemmaMetatheorem.getLabel(),
295
+ substitutions = labelSubstitutions, ///
296
+ labelUnifies = this.unifyLabel(label, substitutions, generalContext, specificContext);
297
+
298
+ if (labelUnifies) {
299
+ const statementSubstitutions = Substitutions.fromNothing(),
300
+ statement = metaLemmaMetatheorem.getStatement(),
301
+ substitutions = statementSubstitutions, ///
302
+ statementUUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
303
+
304
+ if (statementUUnifies) {
305
+ const labelSubstitutionsCorrelateStatementSubstitutions = labelSubstitutions.correlateSubstitutions(statementSubstitutions);
306
+
307
+ if (labelSubstitutionsCorrelateStatementSubstitutions) {
308
+ metaLemmaMetatheoremUnifies = true; ///
309
+ }
310
+ }
311
+ }
312
+
313
+ if (metaLemmaMetatheoremUnifies) {
314
+ context = generalContext; ///
315
+
316
+ context.trace(`...unified the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${assumptionString}' assumption...`);
317
+ }
318
+
319
+ return metaLemmaMetatheoremUnifies;
320
+ }
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
+
337
+ static name = "Assumption";
338
+
339
+ static fromJSON(json, context) {
340
+ let assumption = null;
341
+
342
+ if (json !== null) {
343
+ const string = null,
344
+ node = null,
345
+ statement = null,
346
+ metavariable = metavariableFromJSON(json, context);
347
+
348
+ assumption = new Assumption(string, node, statement, metavariable)
349
+ }
350
+
351
+ return assumption;
352
+ }
353
+
354
+ static fromJudgementNode(judgementNode, context) {
355
+ const assumptionNode = judgementNode.getAssumptionNode(),
356
+ assumption = assumptionFromAssumptionNode(assumptionNode, context);
357
+
358
+ return assumption;
359
+ }
360
+
361
+ static fromAssumptionNode(assumptionNode, context) {
362
+ const assumption = assumptionFromAssumptionNode(assumptionNode, context);
363
+
364
+ return assumption;
365
+ }
366
+ });
367
+
368
+ function referenceFromMetavariable(metavariable, context) {
369
+ const { Reference } = ontology,
370
+ metavariableNode = metavariable.getNode(),
371
+ reference = Reference.fromMetavariableNode(metavariableNode, context);
372
+
373
+ return reference;
374
+ }
375
+
376
+ function assumptionFromAssumptionNode(assumptionNode, context) {
377
+ const { Metavariable, Assumption, Statement } = ontology,
378
+ node = assumptionNode, ///
379
+ string = context.nodeAsString(node),
380
+ statement = Statement.fromAssumptionNode(assumptionNode, context),
381
+ metavariable = Metavariable.fromAssumptionNode(assumptionNode, context),
382
+ assumption = new Assumption(string, node, statement, metavariable);
383
+
384
+ return assumption;
385
+ }
@@ -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),