occam-verify-cli 0.0.1111 → 0.0.1114

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 (197) hide show
  1. package/lib/combinator/bracketed.js +15 -65
  2. package/lib/combinator.js +4 -8
  3. package/lib/constructor/bracketed.js +24 -101
  4. package/lib/constructor.js +4 -8
  5. package/lib/context/file.js +41 -12
  6. package/lib/context/local.js +45 -25
  7. package/lib/context/release.js +2 -2
  8. package/lib/dom/assertion/contained.js +287 -0
  9. package/lib/dom/assertion/defined.js +266 -0
  10. package/lib/dom/assertion/subproof.js +210 -0
  11. package/lib/dom/assertion/type.js +240 -0
  12. package/lib/{axiom.js → dom/axiom.js} +18 -8
  13. package/lib/dom/conclusion.js +171 -0
  14. package/lib/{conjecture.js → dom/conjecture.js} +18 -8
  15. package/lib/dom/consequent.js +171 -0
  16. package/lib/dom/declaration/combinator.js +105 -0
  17. package/lib/dom/declaration/constructor.js +140 -0
  18. package/lib/dom/declaration/metavariable.js +154 -0
  19. package/lib/dom/declaration/type.js +140 -0
  20. package/lib/dom/declaration/variable.js +155 -0
  21. package/lib/{declaration.js → dom/declaration.js} +62 -18
  22. package/lib/dom/derivation.js +137 -0
  23. package/lib/dom/equality.js +260 -0
  24. package/lib/dom/error.js +85 -0
  25. package/lib/dom/frame.js +372 -0
  26. package/lib/dom/judgement.js +198 -0
  27. package/lib/dom/label.js +190 -0
  28. package/lib/{lemma.js → dom/lemma.js} +19 -9
  29. package/lib/{metaLemma.js → dom/metaLemma.js} +19 -9
  30. package/lib/dom/metaType.js +261 -0
  31. package/lib/dom/metatheorem.js +273 -0
  32. package/lib/dom/metavariable.js +463 -0
  33. package/lib/dom/premise.js +221 -0
  34. package/lib/dom/proof.js +154 -0
  35. package/lib/dom/proofStep.js +239 -0
  36. package/lib/dom/reference.js +218 -0
  37. package/lib/dom/rule.js +311 -0
  38. package/lib/dom/statement.js +379 -0
  39. package/lib/dom/subDerivation.js +137 -0
  40. package/lib/dom/subproof.js +211 -0
  41. package/lib/dom/supposition.js +221 -0
  42. package/lib/dom/term.js +354 -0
  43. package/lib/{theorem.js → dom/theorem.js} +18 -8
  44. package/lib/dom/topLevelAssertion.js +306 -0
  45. package/lib/dom/type.js +327 -0
  46. package/lib/dom/variable.js +328 -0
  47. package/lib/dom.js +27 -0
  48. package/lib/equivalences.js +307 -0
  49. package/lib/index.js +40 -35
  50. package/lib/mixins/proofStep/unify.js +86 -0
  51. package/lib/mixins/statement/verify.js +27 -2
  52. package/lib/mixins/term/verify.js +24 -4
  53. package/lib/substitution/frame.js +3 -3
  54. package/lib/substitution/statement.js +17 -16
  55. package/lib/substitution/term.js +10 -7
  56. package/lib/substitution.js +4 -31
  57. package/lib/substitutions.js +24 -56
  58. package/lib/unifier/equality.js +2 -3
  59. package/lib/unifier/label.js +3 -3
  60. package/lib/unifier/metaLevel.js +9 -8
  61. package/lib/unifier/metavariable.js +3 -3
  62. package/lib/unifier/statementWithCombinator.js +5 -5
  63. package/lib/unifier/termWithConstructor.js +3 -3
  64. package/lib/utilities/json.js +26 -40
  65. package/lib/utilities/string.js +6 -8
  66. package/lib/utilities/subproof.js +2 -2
  67. package/lib/utilities/substitutions.js +7 -6
  68. package/lib/utilities/verification.js +22 -14
  69. package/lib/verifier/combinator.js +4 -4
  70. package/lib/verifier/constructor.js +3 -3
  71. package/lib/verifier/topLevel.js +15 -21
  72. package/package.json +1 -1
  73. package/src/combinator/bracketed.js +11 -4
  74. package/src/combinator.js +3 -10
  75. package/src/constructor/bracketed.js +17 -5
  76. package/src/constructor.js +3 -9
  77. package/src/context/file.js +42 -11
  78. package/src/context/local.js +26 -34
  79. package/src/context/release.js +1 -1
  80. package/src/{assertion → dom/assertion}/contained.js +11 -8
  81. package/src/{assertion → dom/assertion}/defined.js +14 -11
  82. package/src/{assertion → dom/assertion}/subproof.js +11 -62
  83. package/src/{assertion → dom/assertion}/type.js +11 -8
  84. package/src/{axiom.js → dom/axiom.js} +6 -9
  85. package/src/dom/conclusion.js +95 -0
  86. package/src/{conjecture.js → dom/conjecture.js} +5 -8
  87. package/src/dom/consequent.js +95 -0
  88. package/src/{declaration → dom/declaration}/combinator.js +8 -5
  89. package/src/{declaration → dom/declaration}/constructor.js +8 -4
  90. package/src/{declaration → dom/declaration}/metavariable.js +8 -5
  91. package/src/{declaration → dom/declaration}/type.js +8 -4
  92. package/src/{declaration → dom/declaration}/variable.js +9 -6
  93. package/src/{declaration.js → dom/declaration.js} +11 -16
  94. package/src/{derivation.js → dom/derivation.js} +9 -12
  95. package/src/{equality.js → dom/equality.js} +11 -14
  96. package/src/{error.js → dom/error.js} +6 -3
  97. package/src/{frame.js → dom/frame.js} +14 -23
  98. package/src/{judgement.js → dom/judgement.js} +8 -11
  99. package/src/{label.js → dom/label.js} +9 -16
  100. package/src/{lemma.js → dom/lemma.js} +5 -9
  101. package/src/{metaLemma.js → dom/metaLemma.js} +6 -9
  102. package/src/{metaType.js → dom/metaType.js} +7 -10
  103. package/src/{metatheorem.js → dom/metatheorem.js} +6 -10
  104. package/src/{metavariable.js → dom/metavariable.js} +79 -77
  105. package/src/dom/premise.js +173 -0
  106. package/src/{proof.js → dom/proof.js} +8 -11
  107. package/src/dom/proofStep.js +173 -0
  108. package/src/{reference.js → dom/reference.js} +48 -20
  109. package/src/{rule.js → dom/rule.js} +13 -17
  110. package/src/{statement.js → dom/statement.js} +142 -71
  111. package/src/{subDerivation.js → dom/subDerivation.js} +9 -12
  112. package/src/{subproof.js → dom/subproof.js} +14 -47
  113. package/src/dom/supposition.js +173 -0
  114. package/src/{term.js → dom/term.js} +24 -45
  115. package/src/{theorem.js → dom/theorem.js} +5 -8
  116. package/src/{topLevelAssertion.js → dom/topLevelAssertion.js} +12 -14
  117. package/src/{type.js → dom/type.js} +9 -12
  118. package/src/{variable.js → dom/variable.js} +20 -28
  119. package/src/dom.js +13 -0
  120. package/src/equivalences.js +278 -0
  121. package/src/index.js +39 -34
  122. package/src/mixins/proofStep/unify.js +115 -0
  123. package/src/mixins/statement/verify.js +33 -1
  124. package/src/mixins/term/verify.js +33 -3
  125. package/src/substitution/frame.js +2 -2
  126. package/src/substitution/statement.js +20 -18
  127. package/src/substitution/term.js +12 -5
  128. package/src/substitution.js +4 -29
  129. package/src/substitutions.js +35 -73
  130. package/src/unifier/equality.js +1 -2
  131. package/src/unifier/label.js +2 -2
  132. package/src/unifier/metaLevel.js +9 -7
  133. package/src/unifier/metavariable.js +2 -2
  134. package/src/unifier/statementWithCombinator.js +4 -4
  135. package/src/unifier/termWithConstructor.js +2 -2
  136. package/src/utilities/json.js +23 -42
  137. package/src/utilities/string.js +8 -6
  138. package/src/utilities/subproof.js +2 -2
  139. package/src/utilities/substitutions.js +7 -5
  140. package/src/utilities/verification.js +29 -13
  141. package/src/verifier/combinator.js +3 -3
  142. package/src/verifier/constructor.js +3 -3
  143. package/src/verifier/topLevel.js +20 -21
  144. package/lib/assertion/contained.js +0 -232
  145. package/lib/assertion/defined.js +0 -211
  146. package/lib/assertion/subproof.js +0 -203
  147. package/lib/assertion/type.js +0 -185
  148. package/lib/conclusion.js +0 -130
  149. package/lib/consequent.js +0 -130
  150. package/lib/declaration/combinator.js +0 -90
  151. package/lib/declaration/constructor.js +0 -90
  152. package/lib/declaration/metavariable.js +0 -104
  153. package/lib/declaration/type.js +0 -90
  154. package/lib/declaration/variable.js +0 -105
  155. package/lib/derivation.js +0 -91
  156. package/lib/equality.js +0 -209
  157. package/lib/error.js +0 -70
  158. package/lib/frame.js +0 -331
  159. package/lib/judgement.js +0 -147
  160. package/lib/label.js +0 -141
  161. package/lib/metaType.js +0 -255
  162. package/lib/metatheorem.js +0 -263
  163. package/lib/metavariable.js +0 -399
  164. package/lib/mixins/statement/qualified/unify.js +0 -69
  165. package/lib/mixins/statement/unify.js +0 -42
  166. package/lib/mixins/statement/unifyIndependenntly.js +0 -46
  167. package/lib/mixins/term/unify.js +0 -40
  168. package/lib/premise.js +0 -184
  169. package/lib/proof.js +0 -103
  170. package/lib/proofStep.js +0 -179
  171. package/lib/reference.js +0 -145
  172. package/lib/rule.js +0 -259
  173. package/lib/shim.js +0 -14
  174. package/lib/statement/qualified.js +0 -152
  175. package/lib/statement/unqualified.js +0 -175
  176. package/lib/statement.js +0 -270
  177. package/lib/subDerivation.js +0 -91
  178. package/lib/subproof.js +0 -181
  179. package/lib/supposition.js +0 -184
  180. package/lib/term.js +0 -318
  181. package/lib/topLevelAssertion.js +0 -305
  182. package/lib/type.js +0 -321
  183. package/lib/utilities/equivalences.js +0 -178
  184. package/lib/variable.js +0 -281
  185. package/src/conclusion.js +0 -96
  186. package/src/consequent.js +0 -96
  187. package/src/mixins/statement/qualified/unify.js +0 -103
  188. package/src/mixins/statement/unify.js +0 -41
  189. package/src/mixins/statement/unifyIndependenntly.js +0 -58
  190. package/src/mixins/term/unify.js +0 -36
  191. package/src/premise.js +0 -183
  192. package/src/proofStep.js +0 -181
  193. package/src/shim.js +0 -5
  194. package/src/statement/qualified.js +0 -133
  195. package/src/statement/unqualified.js +0 -166
  196. package/src/supposition.js +0 -183
  197. package/src/utilities/equivalences.js +0 -183
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ import dom from "../dom";
4
+
5
+ import { domAssigned } from "../dom";
6
+ import { assignAssignments } from "../utilities/assignments";
7
+ import { subproofAssertionFromStatement } from "../utilities/verification";
8
+ import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
9
+
10
+ export default domAssigned(class Premise {
11
+ constructor(string, statement) {
12
+ this.string = string;
13
+ this.statement = statement;
14
+ }
15
+
16
+ getString() {
17
+ return this.string;
18
+ }
19
+
20
+ getStatement() {
21
+ return this.statement;
22
+ }
23
+
24
+ unifyIndependently(substitutions, generalContext, specificContext) {
25
+ let unifiedIndependently;
26
+
27
+ const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
28
+
29
+ unifiedIndependently = statementResolvedIndependently; ///
30
+
31
+ return unifiedIndependently;
32
+ }
33
+
34
+ unifyProofStep(proofStep, substitutions, generalContext, specificContext) {
35
+ let proofStepUnified = false;
36
+
37
+ const subproof = proofStep.getSubproof(),
38
+ statement = proofStep.getStatement();
39
+
40
+ substitutions.snapshot();
41
+
42
+ if (subproof !== null) {
43
+ const subproofUnified = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
44
+
45
+ proofStepUnified = subproofUnified; ///
46
+ }
47
+
48
+ if (statement !== null) {
49
+ const statementUnified = this.unifyStatement(statement, substitutions, generalContext, specificContext);
50
+
51
+ proofStepUnified = statementUnified; ///
52
+ }
53
+
54
+ if (proofStepUnified) {
55
+ substitutions.resolve(generalContext, specificContext);
56
+ }
57
+
58
+ const context = specificContext; ///
59
+
60
+ proofStepUnified ?
61
+ substitutions.continue() :
62
+ substitutions.rollback(context);
63
+
64
+ return proofStepUnified;
65
+ }
66
+
67
+ unifyStatement(statement, substitutions, generalContext, specificContext) {
68
+ let statementUnified;
69
+
70
+ const premise = this, ///
71
+ premiseString = premise.getString(),
72
+ statementString = statement.getString();
73
+
74
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
75
+
76
+ statementUnified = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
77
+
78
+ if (statementUnified) {
79
+ specificContext.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
80
+ }
81
+
82
+ return statementUnified;
83
+ }
84
+
85
+ unifySubproof(subproof, substitutions, generalContext, specificContext) {
86
+ let subproofUnified = false;
87
+
88
+ const premise = this, ///
89
+ subproofString = subproof.getString(),
90
+ premiseStatement = premise.getStatement(),
91
+ premiseStatementString = premiseStatement.getString();
92
+
93
+ specificContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
94
+
95
+ const context = generalContext,
96
+ subproofAssertion = subproofAssertionFromStatement(this.statement, context);
97
+
98
+ if (subproofAssertion !== null) {
99
+ subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
100
+ }
101
+
102
+ if (subproofUnified) {
103
+ specificContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
104
+ }
105
+
106
+ return subproofUnified;
107
+ }
108
+
109
+ verify(context) {
110
+ let verified = false;
111
+
112
+ const premiseString = this.string; ///
113
+
114
+ if (this.statement !== null) {
115
+ context.trace(`Verifying the '${premiseString}' premise...`);
116
+
117
+ const stated = true,
118
+ assignments = [],
119
+ statementVerified = this.statement.verify(assignments, stated, context);
120
+
121
+ if (statementVerified) {
122
+ const assignmentsAssigned = assignAssignments(assignments, context);
123
+
124
+ if (assignmentsAssigned) {
125
+ const { ProofStep } = dom,
126
+ proofStep = ProofStep.fromStatement(this.statement, context);
127
+
128
+ context.addProofStep(proofStep);
129
+
130
+ verified = true;
131
+ }
132
+ }
133
+
134
+ if (verified) {
135
+ context.debug(`...verified the '${premiseString}' premise.`);
136
+ }
137
+ } else {
138
+ context.debug(`Unable to verify the '${premiseString}' premise because it is nonsense.`);
139
+ }
140
+
141
+ return verified;
142
+ }
143
+
144
+ toJSON() {
145
+ const statementJSON = statementToStatementJSON(this.statement),
146
+ statement = statementJSON, ///
147
+ json = {
148
+ statement
149
+ };
150
+
151
+ return json;
152
+ }
153
+
154
+ static name = "Premise";
155
+
156
+ static fromJSON(json, fileContext) {
157
+ const statement = statementFromJSON(json, fileContext),
158
+ string = statement.getString(),
159
+ premise = new Premise(string, statement);
160
+
161
+ return premise;
162
+ }
163
+
164
+ static fromPremiseNode(premiseNode, fileContext) {
165
+ const { Statement } = dom,
166
+ statement = Statement.fromPremiseNode(premiseNode, fileContext),
167
+ statementString = statement.getString(),
168
+ string = statementString, ///
169
+ premise = new Premise(string, statement);
170
+
171
+ return premise
172
+ }
173
+ });
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
 
3
- import shim from "./shim";
4
- import LocalContext from "./context/local";
3
+ import dom from "../dom";
4
+ import LocalContext from "../context/local";
5
5
 
6
- import { nodeQuery } from "./utilities/query";
6
+ import { nodeQuery } from "../utilities/query";
7
+ import { domAssigned } from "../dom";
7
8
 
8
9
  const derivationNodeQuery = nodeQuery("/proof/derivation");
9
10
 
10
- class Proof {
11
+ export default domAssigned(class Proof {
11
12
  constructor(derivation) {
12
13
  this.derivation = derivation;
13
14
  }
@@ -52,11 +53,13 @@ class Proof {
52
53
  return verified;
53
54
  }
54
55
 
56
+ static name = "Proof";
57
+
55
58
  static fromProofNode(proofNode, fileContext) {
56
59
  let proof = null;
57
60
 
58
61
  if (proofNode !== null) {
59
- const { Derivation } = shim,
62
+ const { Derivation } = dom,
60
63
  derivationNode = derivationNodeQuery(proofNode),
61
64
  derivation = Derivation.fromDerivationNode(derivationNode, fileContext);
62
65
 
@@ -65,10 +68,4 @@ class Proof {
65
68
 
66
69
  return proof;
67
70
  }
68
- }
69
-
70
- Object.assign(shim, {
71
- Proof
72
71
  });
73
-
74
- export default Proof;
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ import dom from "../dom";
4
+ import unifyMixins from "../mixins/proofStep/unify";
5
+ import Substitutions from "../substitutions";
6
+
7
+ import { domAssigned } from "../dom";
8
+ import { assignAssignments } from "../utilities/assignments";
9
+
10
+ export default domAssigned(class ProofStep {
11
+ constructor(string, subproof, statement, reference) {
12
+ this.string = string;
13
+ this.subproof = subproof;
14
+ this.statement = statement;
15
+ this.reference = reference;
16
+ }
17
+
18
+ getString() {
19
+ return this.string;
20
+ }
21
+
22
+ getSubproof() {
23
+ return this.subproof;
24
+ }
25
+
26
+ getStatement() {
27
+ return this.statement;
28
+ }
29
+
30
+ getReference() {
31
+ return this.reference;
32
+ }
33
+
34
+ isQualified() {
35
+ const qualified = (this.reference !== null);
36
+
37
+ return qualified;
38
+ }
39
+
40
+ unify(substitutions, context) {
41
+ let unified;
42
+
43
+ if (this.subproof !== null) {
44
+ unified = true; ///
45
+ }
46
+
47
+ if (this.statement !== null) {
48
+ const proofStepString = this.string; ///
49
+
50
+ context.trace(`Unifying the '${proofStepString}' proof step...`);
51
+
52
+ unified = unifyMixins.some((unifyMixin) => {
53
+ const unified = unifyMixin(this.statement, this.reference, substitutions, context);
54
+
55
+ if (unified) {
56
+ return true;
57
+ }
58
+ });
59
+
60
+ if (unified) {
61
+ context.debug(`...unified the '${proofStepString}' proof step.`);
62
+ }
63
+ }
64
+
65
+ return unified;
66
+ }
67
+
68
+ unifyStatement(statement, context) {
69
+ let statementUnified;
70
+
71
+ const specificContext = context, ///
72
+ generalContext = context, ///
73
+ substitutions = Substitutions.fromNothing();
74
+
75
+ if (this.subproof !== null) {
76
+ const subproofUnified = statement.unifySubproof(this.subproof, substitutions, generalContext, specificContext);
77
+
78
+ statementUnified = subproofUnified; ///
79
+ }
80
+
81
+ if (this.statement !== null) {
82
+ statementUnified = statement.unifyStatement(this.statement, substitutions, generalContext, specificContext);
83
+ }
84
+
85
+ if (statementUnified) {
86
+ const equivalences = context.getEquivalences(),
87
+ substitutionsUnified = equivalences.unifySubstitutions(substitutions);
88
+
89
+ statementUnified = substitutionsUnified; ///
90
+ }
91
+
92
+ return statementUnified;
93
+ }
94
+
95
+ verifyAndUnify(substitutions, context) {
96
+ let verifiedAndUnified = false;
97
+
98
+ const assignments = [],
99
+ verified = this.verify(substitutions, assignments, context);
100
+
101
+ if (verified) {
102
+ const unified = this.unify(substitutions, context);
103
+
104
+ if (unified) {
105
+ const proofStep = this; ///
106
+
107
+ assignAssignments(assignments, context);
108
+
109
+ context.addProofStep(proofStep);
110
+ }
111
+
112
+ verifiedAndUnified = unified; ///
113
+ }
114
+
115
+ return verifiedAndUnified;
116
+ }
117
+
118
+ verify(substitutions, assignments, context) {
119
+ let verified = false;
120
+
121
+ if (false) {
122
+ ///
123
+ } else if (this.subproof !== null) {
124
+ const subproofVerified = this.subproof.verify(substitutions, context);
125
+
126
+ verified = subproofVerified; ///
127
+ } else if (this.statement !== null) {
128
+ const qualified = this.isQualified(),
129
+ stated = qualified, ///
130
+ statementVerified = this.statement.verify(assignments, stated, context);
131
+
132
+ if (statementVerified) {
133
+ if (this.reference === null) {
134
+ verified = true;
135
+ } else {
136
+ const referenceVerified = this.reference.verify(context);
137
+
138
+ verified = referenceVerified; ///
139
+ }
140
+ }
141
+ } else {
142
+ const proofStepString = this.string;
143
+
144
+ context.debug(`Cannot verify the '${proofStepString}' proof step because it is nonsense.`);
145
+ }
146
+
147
+ return verified;
148
+ }
149
+
150
+ static name = "ProofStep";
151
+
152
+ static fromStatement(statement, context) {
153
+ const statementString = statement.getString(),
154
+ string = statementString, ///
155
+ subproof = null,
156
+ reference = null,
157
+ proofStep = new ProofStep(string, subproof, statement, reference);
158
+
159
+ return proofStep;
160
+ }
161
+
162
+ static fromProofStepNode(proofStepNode, fileContext) {
163
+ const { Subproof, Statement, Reference } = dom,
164
+ node = proofStepNode, ///
165
+ string = fileContext.nodeAsString(node),
166
+ subproof = Subproof.fromProofStepNode(proofStepNode, fileContext),
167
+ statement = Statement.fromProofStepNode(proofStepNode, fileContext),
168
+ reference = Reference.fromProofStepNode(proofStepNode, fileContext),
169
+ proofStep = new ProofStep(string, subproof, statement, reference);
170
+
171
+ return proofStep;
172
+ }
173
+ });
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
 
3
- import shim from "./shim";
4
- import LocalContext from "./context/local";
3
+ import dom from "../dom";
4
+ import LocalContext from "../context/local";
5
5
 
6
- import { nodeQuery } from "./utilities/query";
7
- import { referenceMetaType } from "./metaType";
8
- import { unifyLabelWithReference } from "./utilities/unification";
9
- import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
6
+ import { nodeQuery } from "../utilities/query";
7
+ import { domAssigned } from "../dom";
8
+ import { referenceMetaType } from "../dom/metaType";
9
+ import { unifyLabelWithReference } from "../utilities/unification";
10
+ import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
10
11
 
11
- const metavariableNodeQuery = nodeQuery("//reference/metavariable");
12
+ const referenceNodeQuery = nodeQuery("/proofStep|lastProofStep/reference");
12
13
 
13
- export default class Reference {
14
+ export default domAssigned(class Reference {
14
15
  constructor(metavariable) {
15
16
  this.metavariable = metavariable;
16
17
  }
@@ -40,7 +41,7 @@ export default class Reference {
40
41
  unifyLabel(label, substitutions, generalContext, specificContext) {
41
42
  let labelUnified;
42
43
 
43
- const reference = this,
44
+ const reference = this, ///
44
45
  labelString = label.getString(),
45
46
  referenceString = reference.getString();
46
47
 
@@ -65,10 +66,18 @@ export default class Reference {
65
66
  context.trace(`Verifying the '${referenceString}' reference...`);
66
67
 
67
68
  if (!verified) {
68
- const metaType = referenceMetaType, ///
69
- metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, context);
69
+ const metavariableVerified = this.verifyMetavariable(context);
70
70
 
71
- verified = metavariableVerifiedGivenMetaType; ///
71
+ verified = metavariableVerified; ///
72
+ }
73
+
74
+ if (!verified) {
75
+ const reference = this, ///
76
+ rulePresent = context.isRulePresentByReference(reference),
77
+ metaLemmasMetaTheoremsPresent = context.areMetaLemmasMetaTheoremsPresentByReference(reference),
78
+ axiomLemmaTheoremConjecturePresent = context.isAxiomLemmaTheoremConjecturePresentByReference(reference);
79
+
80
+ verified = (rulePresent || metaLemmasMetaTheoremsPresent || axiomLemmaTheoremConjecturePresent);
72
81
  }
73
82
 
74
83
  if (verified) {
@@ -78,6 +87,17 @@ export default class Reference {
78
87
  return verified;
79
88
  }
80
89
 
90
+ verifyMetavariable(context) {
91
+ let metavariableVerified;
92
+
93
+ const metaType = referenceMetaType, ///
94
+ metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, context);
95
+
96
+ metavariableVerified = metavariableVerifiedGivenMetaType; ///
97
+
98
+ return metavariableVerified;
99
+ }
100
+
81
101
  toJSON() {
82
102
  const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
83
103
  metavariable = metavariableJSON, ///
@@ -90,6 +110,8 @@ export default class Reference {
90
110
  return json;
91
111
  }
92
112
 
113
+ static name = "Reference";
114
+
93
115
  static fromJSON(json, fileContext) {
94
116
  const metavariable = metavariableFromJSON(json, fileContext),
95
117
  reference = new Reference(string, metavariable);
@@ -97,14 +119,20 @@ export default class Reference {
97
119
  return reference;
98
120
  }
99
121
 
100
- static fromReferenceNode(referenceNode, fileContext) {
101
- const { Metavariable } = shim,
102
- metavariableNode = metavariableNodeQuery(referenceNode),
103
- localContext = LocalContext.fromFileContext(fileContext),
104
- context = localContext, ///
105
- metavariable = Metavariable.fromMetavariableNode(metavariableNode, context),
106
- reference = new Reference(metavariable);
122
+ static fromProofStepNode(proofStepNode, fileContext) {
123
+ let reference = null;
124
+
125
+ const referenceNode = referenceNodeQuery(proofStepNode);
126
+
127
+ if (referenceNode !== null) {
128
+ const { Metavariable } = dom,
129
+ localContext = LocalContext.fromFileContext(fileContext),
130
+ context = localContext, ///
131
+ metavariable = Metavariable.fromReferenceNode(referenceNode, context);
132
+
133
+ reference = new Reference(metavariable);
134
+ }
107
135
 
108
136
  return reference;
109
137
  }
110
- }
138
+ });
@@ -2,26 +2,28 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import shim from "./shim";
6
- import LocalContext from "./context/local";
5
+ import dom from "../dom";
6
+ import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
7
8
 
9
+ import { domAssigned } from "../dom";
8
10
  import { stringFromLabels } from "./topLevelAssertion";
9
- import { nodeQuery, nodesQuery } from "./utilities/query";
11
+ import { nodeQuery, nodesQuery } from "../utilities/query";
10
12
  import { labelsFromJSON,
11
13
  premisesFromJSON,
12
14
  conclusionFromJSON,
13
15
  labelsToLabelsJSON,
14
16
  premisesToPremisesJSON,
15
- conclusionToConclusionJSON } from "./utilities/json";
17
+ conclusionToConclusionJSON } from "../utilities/json";
16
18
 
17
- const { extract, reverse, backwardsEvery } = arrayUtilities;
19
+ const { reverse, extract, backwardsEvery } = arrayUtilities;
18
20
 
19
21
  const proofNodeQuery = nodeQuery("/rule/proof"),
20
22
  labelNodesQuery = nodesQuery("/rule/label"),
21
23
  premiseNodesQuery = nodesQuery("/rule/premise"),
22
24
  conclusionNodeQuery = nodeQuery("/rule/conclusion");
23
25
 
24
- class Rule {
26
+ export default domAssigned(class Rule {
25
27
  constructor(fileContext, string, labels, premises, conclusion, proof) {
26
28
  this.fileContext = fileContext;
27
29
  this.string = string;
@@ -76,8 +78,7 @@ class Rule {
76
78
  generalContext = localContext, ///
77
79
  specificContext = context; ///
78
80
 
79
- const { Substitutions } = shim,
80
- substitutions = Substitutions.fromNothing(),
81
+ const substitutions = Substitutions.fromNothing(),
81
82
  statementUnifiedWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, generalContext, specificContext);
82
83
 
83
84
  if (statementUnifiedWithConclusion) {
@@ -167,8 +168,7 @@ class Rule {
167
168
  let proofVerified = true; ///
168
169
 
169
170
  if (this.proof !== null) {
170
- const { Substitutions } = shim,
171
- substitutions = Substitutions.fromNothing();
171
+ const substitutions = Substitutions.fromNothing();
172
172
 
173
173
  proofVerified = this.proof.verify(substitutions, this.conclusion, context);
174
174
  }
@@ -220,6 +220,8 @@ class Rule {
220
220
  return json;
221
221
  }
222
222
 
223
+ static name = "Rule";
224
+
223
225
  static fromJSON(json, fileContext) {
224
226
  let rule;
225
227
 
@@ -235,7 +237,7 @@ class Rule {
235
237
  }
236
238
 
237
239
  static fromRuleNode(ruleNode, fileContext) {
238
- const { Label, Proof, Premise, Conclusion } = shim,
240
+ const { Label, Proof, Premise, Conclusion } = dom,
239
241
  proofNode = proofNodeQuery(ruleNode),
240
242
  labelNodes = labelNodesQuery(ruleNode),
241
243
  premiseNodes = premiseNodesQuery(ruleNode),
@@ -257,10 +259,4 @@ class Rule {
257
259
 
258
260
  return rule;
259
261
  }
260
- }
261
-
262
- Object.assign(shim, {
263
- Rule
264
262
  });
265
-
266
- export default Rule;