occam-verify-cli 0.0.1073 → 0.0.1075

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 (141) hide show
  1. package/lib/assertion/type.js +47 -54
  2. package/lib/assignment/equality.js +8 -2
  3. package/lib/assignment/variable.js +2 -2
  4. package/lib/axiom.js +9 -12
  5. package/lib/combinator/bracketed.js +3 -2
  6. package/lib/combinator.js +6 -6
  7. package/lib/conclusion.js +2 -3
  8. package/lib/conjecture.js +10 -15
  9. package/lib/consequent.js +2 -3
  10. package/lib/constructor/bracketed.js +3 -2
  11. package/lib/constructor.js +6 -6
  12. package/lib/context/file.js +48 -107
  13. package/lib/context/local.js +52 -73
  14. package/lib/declaration/combinator.js +5 -5
  15. package/lib/declaration/constructor.js +5 -5
  16. package/lib/declaration/metavariable.js +4 -5
  17. package/lib/declaration/type.js +3 -3
  18. package/lib/declaration/variable.js +5 -5
  19. package/lib/declaration.js +6 -2
  20. package/lib/derivation.js +6 -2
  21. package/lib/equality.js +53 -22
  22. package/lib/equivalence.js +22 -24
  23. package/lib/frame.js +11 -13
  24. package/lib/index.js +13 -1
  25. package/lib/judgement.js +11 -8
  26. package/lib/label.js +6 -7
  27. package/lib/lemma.js +10 -15
  28. package/lib/metaLemma.js +15 -15
  29. package/lib/metatheorem.js +9 -14
  30. package/lib/metavariable.js +17 -23
  31. package/lib/mixins/statement/qualified/unify.js +2 -2
  32. package/lib/mixins/statement/verify.js +8 -12
  33. package/lib/mixins/term/verify.js +4 -4
  34. package/lib/premise.js +2 -3
  35. package/lib/proof.js +8 -4
  36. package/lib/proofStep.js +10 -8
  37. package/lib/reference.js +3 -3
  38. package/lib/rule.js +11 -16
  39. package/lib/statement/qualified.js +6 -2
  40. package/lib/statement/unqualified.js +1 -1
  41. package/lib/statement.js +5 -5
  42. package/lib/subDerivation.js +6 -2
  43. package/lib/subproof.js +10 -7
  44. package/lib/substitution/statementForMetavariable.js +14 -15
  45. package/lib/substitution.js +13 -13
  46. package/lib/substitutions.js +51 -47
  47. package/lib/supposition.js +2 -3
  48. package/lib/term.js +5 -5
  49. package/lib/theorem.js +10 -15
  50. package/lib/topLevelAssertion.js +3 -3
  51. package/lib/type.js +15 -22
  52. package/lib/unifier/equality.js +2 -2
  53. package/lib/unifier/metaLevel.js +6 -6
  54. package/lib/unifier/metavariable.js +5 -5
  55. package/lib/unifier/statementWithCombinator.js +2 -2
  56. package/lib/utilities/brackets.js +2 -2
  57. package/lib/utilities/equivalences.js +8 -8
  58. package/lib/utilities/node.js +2 -7
  59. package/lib/utilities/nominal.js +26 -0
  60. package/lib/utilities/subproof.js +2 -2
  61. package/lib/utilities/tokens.js +3 -7
  62. package/lib/variable.js +13 -9
  63. package/lib/verifier/metaLevel.js +2 -2
  64. package/lib/verifier/statementAsCombinator.js +2 -2
  65. package/lib/verifier/termAsConstructor.js +2 -2
  66. package/lib/verifier/topLevel.js +9 -15
  67. package/package.json +1 -1
  68. package/src/assertion/type.js +52 -57
  69. package/src/assignment/equality.js +3 -1
  70. package/src/assignment/variable.js +2 -1
  71. package/src/axiom.js +6 -8
  72. package/src/combinator/bracketed.js +6 -3
  73. package/src/combinator.js +4 -4
  74. package/src/conclusion.js +2 -2
  75. package/src/conjecture.js +8 -11
  76. package/src/consequent.js +2 -2
  77. package/src/constructor/bracketed.js +6 -3
  78. package/src/constructor.js +4 -4
  79. package/src/context/file.js +46 -90
  80. package/src/context/local.js +51 -90
  81. package/src/declaration/combinator.js +5 -4
  82. package/src/declaration/constructor.js +5 -4
  83. package/src/declaration/metavariable.js +3 -4
  84. package/src/declaration/type.js +2 -2
  85. package/src/declaration/variable.js +5 -4
  86. package/src/declaration.js +7 -1
  87. package/src/derivation.js +7 -1
  88. package/src/equality.js +80 -27
  89. package/src/equivalence.js +30 -28
  90. package/src/frame.js +10 -9
  91. package/src/index.js +12 -0
  92. package/src/judgement.js +11 -5
  93. package/src/label.js +5 -5
  94. package/src/lemma.js +8 -11
  95. package/src/metaLemma.js +13 -11
  96. package/src/metatheorem.js +6 -10
  97. package/src/metavariable.js +18 -34
  98. package/src/mixins/statement/qualified/unify.js +1 -2
  99. package/src/mixins/statement/verify.js +19 -18
  100. package/src/mixins/term/verify.js +4 -3
  101. package/src/premise.js +2 -2
  102. package/src/proof.js +10 -3
  103. package/src/proofStep.js +12 -7
  104. package/src/reference.js +3 -2
  105. package/src/rule.js +10 -12
  106. package/src/statement/qualified.js +7 -1
  107. package/src/statement/unqualified.js +0 -1
  108. package/src/statement.js +3 -3
  109. package/src/subDerivation.js +8 -2
  110. package/src/subproof.js +12 -5
  111. package/src/substitution/statementForMetavariable.js +12 -12
  112. package/src/substitution.js +9 -9
  113. package/src/substitutions.js +42 -34
  114. package/src/supposition.js +2 -2
  115. package/src/term.js +3 -3
  116. package/src/theorem.js +8 -11
  117. package/src/topLevelAssertion.js +3 -2
  118. package/src/type.js +15 -28
  119. package/src/unifier/equality.js +1 -1
  120. package/src/unifier/metaLevel.js +8 -10
  121. package/src/unifier/metavariable.js +5 -5
  122. package/src/unifier/statementWithCombinator.js +5 -5
  123. package/src/utilities/brackets.js +2 -2
  124. package/src/utilities/equivalences.js +9 -9
  125. package/src/utilities/node.js +1 -10
  126. package/src/utilities/nominal.js +14 -0
  127. package/src/utilities/subproof.js +2 -2
  128. package/src/utilities/tokens.js +2 -9
  129. package/src/variable.js +16 -11
  130. package/src/verifier/metaLevel.js +2 -2
  131. package/src/verifier/statementAsCombinator.js +3 -3
  132. package/src/verifier/termAsConstructor.js +2 -2
  133. package/src/verifier/topLevel.js +15 -14
  134. package/lib/assignment/metavariable.js +0 -62
  135. package/lib/unifier/intrinsicLevel.js +0 -144
  136. package/lib/utilities/unify.js +0 -24
  137. package/lib/verifier/intrinsicLevel.js +0 -140
  138. package/src/assignment/metavariable.js +0 -30
  139. package/src/unifier/intrinsicLevel.js +0 -54
  140. package/src/utilities/unify.js +0 -23
  141. package/src/verifier/intrinsicLevel.js +0 -42
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { nodeQuery } from "./utilities/query";
4
4
  import { stripBracketsFromTermNode } from "./utilities/brackets";
5
- import { variableNameFromVariableNode } from "./utilities/name";
6
5
 
7
6
  const variableNodeQuery = nodeQuery("/term/variable!");
8
7
 
@@ -15,17 +14,18 @@ export default class Equivalence {
15
14
  return this.terms;
16
15
  }
17
16
 
18
- setTerms(terms) {
19
- this.terms = terms;
20
- }
17
+ addTerm(term, localContext) {
18
+ const termString = term.getString(),
19
+ equivalenceString = this.asString(); ///
20
+
21
+ localContext.trace(`Adding the '${termString}' term to the '${equivalenceString}' equivalence.`);
21
22
 
22
- addTerm(term) {
23
23
  this.terms.push(term);
24
24
  }
25
25
 
26
- getType(localContext) {
26
+ getType() {
27
27
  const type = this.terms.reduce((type, term) => {
28
- const termType = termTypeFromTerm(term, localContext);
28
+ const termType = term.getType();
29
29
 
30
30
  if (type === null) {
31
31
  type = termType; ///
@@ -43,10 +43,10 @@ export default class Equivalence {
43
43
  return type;
44
44
  }
45
45
 
46
- matchType(type, localContext) {
46
+ matchType(type) {
47
47
  const typeA = type; ///
48
48
 
49
- type = this.getType(localContext);
49
+ type = this.getType();
50
50
 
51
51
  const typeB = type; ///
52
52
 
@@ -198,6 +198,27 @@ export default class Equivalence {
198
198
  return implicitlyGroundedTerms;
199
199
  }
200
200
 
201
+ asString() {
202
+ let string;
203
+
204
+ string = this.terms.reduce((string, term) => {
205
+ const termString = term.getString();
206
+
207
+ string = (string === null) ?
208
+ termString :
209
+ `${string} ${termString}`;
210
+
211
+ return string;
212
+ }, null);
213
+
214
+ const type = this.getType(),
215
+ typeString = type.getString();
216
+
217
+ string = `${string}:${typeString}`;
218
+
219
+ return string;
220
+ }
221
+
201
222
  static merge(leftEquivalence, rightEquivalence) {
202
223
  const leftEquivalenceTerms = leftEquivalence.getTerms(),
203
224
  rightEquivalenceTerms = rightEquivalence.getTerms(),
@@ -220,22 +241,3 @@ export default class Equivalence {
220
241
  return equivalence;
221
242
  }
222
243
  }
223
-
224
- function termTypeFromTerm(term, localContext) {
225
- let termType;
226
-
227
- const termNode = term.getNode(),
228
- variableNode = variableNodeQuery(termNode);
229
-
230
- if (variableNode !== null) {
231
- const variableName = variableNameFromVariableNode(variableNode),
232
- variable = localContext.findVariableByVariableName(variableName),
233
- variableType = variable.getType();
234
-
235
- termType = variableType; ///
236
- } else {
237
- termType = term.getType();
238
- }
239
-
240
- return termType;
241
- }
package/src/frame.js CHANGED
@@ -3,8 +3,6 @@
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
5
  import shim from "./shim";
6
- import Declaration from "./declaration";
7
- import Metavariable from "./metavariable";
8
6
 
9
7
  import { FRAME_META_TYPE_NAME } from "./metaTypeNames";
10
8
  import { nodeQuery, nodesQuery } from "./utilities/query";
@@ -76,16 +74,16 @@ class Frame {
76
74
  return frameNodeMatches;
77
75
  }
78
76
 
79
- matchMetavariableName(metavariableName) {
80
- let metavariableNameMatches = false;
77
+ matchMetavariableNode(metavariableNode) {
78
+ let metavariableNodeMatches = false;
81
79
 
82
80
  const metavariable = this.getMetavariable();
83
81
 
84
82
  if (metavariable !== null) {
85
- metavariableNameMatches = metavariable.matchMetavariableName(metavariableName);
83
+ metavariableNodeMatches = metavariable.matchMetavariableNode(metavariableNode);
86
84
  }
87
85
 
88
- return metavariableNameMatches;
86
+ return metavariableNodeMatches;
89
87
  }
90
88
 
91
89
  unifySubstitution(substitution, localContext) {
@@ -259,7 +257,8 @@ class Frame {
259
257
  let frame = null;
260
258
 
261
259
  if (frameNode !== null) {
262
- const declarationNodes = declarationNodesQuery(frameNode),
260
+ const { Declaration, Metavariable } = shim,
261
+ declarationNodes = declarationNodesQuery(frameNode),
263
262
  metavariableNodes = metavariableNodesQuery(frameNode),
264
263
  declarations = declarationNodes.map((declarationNode) => {
265
264
  const declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
@@ -289,7 +288,8 @@ class Frame {
289
288
  const metavariableNode = metavariableNodeQuery(frameNode);
290
289
 
291
290
  if (metavariableNode !== null) {
292
- const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
291
+ const { Metavariable } = shim,
292
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
293
293
  declarations = [],
294
294
  metavariables = [
295
295
  metavariable
@@ -313,7 +313,8 @@ class Frame {
313
313
  const metavariableNode = metavariableNodeQuery(frameNode);
314
314
 
315
315
  if (metavariableNode !== null) {
316
- const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
316
+ const { Metavariable } = shim,
317
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
317
318
  declarations = [],
318
319
  metavariables = [
319
320
  metavariable
package/src/index.js CHANGED
@@ -6,20 +6,32 @@ import Rule from "./rule";
6
6
  import Label from "./label";
7
7
  import Axiom from "./axiom";
8
8
  import Lemma from "./lemma";
9
+ import Frame from "./frame";
10
+ import Proof from "./proof";
9
11
  import Premise from "./premise";
10
12
  import Theorem from "./theorem";
13
+ import Equality from "./equality";
11
14
  import MetaType from "./metaType";
15
+ import Subproof from "./subproof";
12
16
  import Variable from "./variable";
13
17
  import Statement from "./statement";
14
18
  import ProofStep from "./proofStep";
19
+ import Judgement from "./judgement";
20
+ import MetaLemma from "./metaLemma";
15
21
  import Consequent from "./consequent";
16
22
  import Conjecture from "./conjecture";
17
23
  import Combinator from "./combinator";
18
24
  import Conclusion from "./conclusion";
25
+ import Derivation from "./derivation";
26
+ import Declaration from "./declaration";
19
27
  import Constructor from "./constructor";
20
28
  import Supposition from "./supposition";
21
29
  import Metatheorem from "./metatheorem";
22
30
  import Metavariable from "./metavariable";
31
+ import Substitution from "./substitution";
32
+ import Substitutions from "./substitutions";
33
+ import SubDerivation from "./subDerivation";
34
+ import QualifiedStatement from "./statement/qualified";
23
35
  import UnqualifiedStatement from "./statement/unqualified";
24
36
 
25
37
  export { default as Log } from "./log";
package/src/judgement.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import Frame from "./frame";
4
- import Declaration from "./declaration";
3
+ import shim from "./shim";
5
4
  import JudgementAssignment from "./assignment/judgement";
6
5
 
7
6
  import { nodeQuery } from "./utilities/query";
@@ -9,7 +8,7 @@ import { nodeQuery } from "./utilities/query";
9
8
  const frameNodeQuery = nodeQuery("/judgement/frame"),
10
9
  declarationNodeQuery = nodeQuery("/judgement/declaration");
11
10
 
12
- export default class Judgement {
11
+ class Judgement {
13
12
  constructor(string, frame, declaration) {
14
13
  this.string = string;
15
14
  this.frame = frame;
@@ -30,7 +29,7 @@ export default class Judgement {
30
29
 
31
30
  getMetavariableNode() { return this.frame.getMetavariableNode(); }
32
31
 
33
- matchMetavariableName(metavariableName) { return this.frame.matchMetavariableName(metavariableName); }
32
+ matchMetavariableNode(metavariableNode) { return this.frame.matchMetavariableNode(metavariableNode); }
34
33
 
35
34
  verify(assignments, stated, localContext) {
36
35
  let verified;
@@ -117,7 +116,8 @@ export default class Judgement {
117
116
  let judgement = null;
118
117
 
119
118
  if (judgementNode !== null) {
120
- const frameNode = frameNodeQuery(judgementNode),
119
+ const { Frame, Declaration } = shim,
120
+ frameNode = frameNodeQuery(judgementNode),
121
121
  declarationNode = declarationNodeQuery(judgementNode),
122
122
  node = judgementNode, ///
123
123
  string = localContext.nodeAsString(node),
@@ -130,3 +130,9 @@ export default class Judgement {
130
130
  return judgement;
131
131
  }
132
132
  }
133
+
134
+ Object.assign(shim, {
135
+ Judgement
136
+ });
137
+
138
+ export default Judgement;
package/src/label.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  import shim from "./shim";
4
4
  import LocalContext from "./context/local";
5
- import Metavariable from "./metavariable";
6
5
 
7
6
  import { nodeQuery } from "./utilities/query";
8
7
  import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
@@ -22,12 +21,12 @@ class Label {
22
21
 
23
22
  matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
24
23
 
25
- verifyAtTopLevel(fileContext) {
24
+ verifyWhenDeclared(fileContext) {
26
25
  let verifiedAtTopLevel = false;
27
26
 
28
27
  const labelString = this.getString(); ///
29
28
 
30
- fileContext.trace(`Verifying the '${labelString}' label at top level...`);
29
+ fileContext.trace(`Verifying the '${labelString}' label when declared...`);
31
30
 
32
31
  const metavariableNode = this.metavariable.getNode(),
33
32
  labelPresent = fileContext.isLabelPresentByMetavariableNode(metavariableNode);
@@ -39,7 +38,7 @@ class Label {
39
38
  }
40
39
 
41
40
  if (verifiedAtTopLevel) {
42
- fileContext.debug(`...verified the '${labelString}' label at top level.`);
41
+ fileContext.debug(`...verified the '${labelString}' label when declared.`);
43
42
  }
44
43
 
45
44
  return verifiedAtTopLevel;
@@ -63,7 +62,8 @@ class Label {
63
62
  }
64
63
 
65
64
  static fromLabelNode(labelNode, fileContext) {
66
- const metavariableNode = metavariableNodeQuery(labelNode),
65
+ const { Metavariable } = shim,
66
+ metavariableNode = metavariableNodeQuery(labelNode),
67
67
  localContext = LocalContext.fromFileContext(fileContext),
68
68
  metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
69
69
  label = new Label(metavariable);
package/src/lemma.js CHANGED
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import shim from "./shim";
4
- import Label from "./label";
5
- import Proof from "./proof";
6
- import Consequent from "./consequent";
7
- import Supposition from "./supposition";
8
4
  import LocalContext from "./context/local";
9
- import Substitutions from "./substitutions";
10
5
  import TopLevelAssertion from "./topLevelAssertion";
11
6
 
12
7
  import { EMPTY_STRING } from "./constants";
@@ -28,15 +23,15 @@ class Lemma extends TopLevelAssertion {
28
23
  this.fileContext.trace(`Verifying a lemma...`) :
29
24
  this.fileContext.trace(`Verifying the '${lemmaString}' lemma...`);
30
25
 
31
- const labelsVerifiedAtTopLevel = this.labels.every((label) => {
32
- const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
26
+ const labelsVerifiedWhenDeclared = this.labels.every((label) => {
27
+ const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
33
28
 
34
- if (labelVVerifiedAtTopLevel) {
29
+ if (labelVVerifiedWhenDeclared) {
35
30
  return true;
36
31
  }
37
32
  });
38
33
 
39
- if (labelsVerifiedAtTopLevel) {
34
+ if (labelsVerifiedWhenDeclared) {
40
35
  const localContext = LocalContext.fromFileContext(this.fileContext),
41
36
  suppositionsVerified = this.suppositions.every((supposition) => {
42
37
  const suppositionVerified = supposition.verify(localContext);
@@ -50,7 +45,8 @@ class Lemma extends TopLevelAssertion {
50
45
  const consequentVerified = this.consequent.verify(localContext);
51
46
 
52
47
  if (consequentVerified) {
53
- const substitutions = Substitutions.fromNothing(),
48
+ const { Substitutions } = shim,
49
+ substitutions = Substitutions.fromNothing(),
54
50
  proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
55
51
 
56
52
  if (proofVerified) {
@@ -74,7 +70,8 @@ class Lemma extends TopLevelAssertion {
74
70
  }
75
71
 
76
72
  static fromLemmaNode(lemmaNode, fileContext) {
77
- const proofNode = proofNodeQuery(lemmaNode),
73
+ const { Label, Proof, Supposition, Consequent } = shim,
74
+ proofNode = proofNodeQuery(lemmaNode),
78
75
  labelNodes = labelNodesQuery(lemmaNode),
79
76
  consequentNode = consequentNodeQuery(lemmaNode),
80
77
  suppositionNodes = suppositionNodesQuery(lemmaNode),
package/src/metaLemma.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import Label from "./label";
4
- import Proof from "./proof";
5
- import Consequent from "./consequent";
6
- import Supposition from "./supposition";
3
+ import shim from "./shim";
7
4
  import LocalContext from "./context/local";
8
- import Substitutions from "./substitutions";
9
5
  import TopLevelAssertion from "./topLevelAssertion";
10
6
 
11
7
  import { EMPTY_STRING } from "./constants";
@@ -17,7 +13,7 @@ const proofNodeQuery = nodeQuery("/metaLemma/proof"),
17
13
  consequentNodeQuery = nodeQuery("/metaLemma/consequent"),
18
14
  suppositionNodesQuery = nodesQuery("/metaLemma/supposition");
19
15
 
20
- export default class MetaLemma extends TopLevelAssertion {
16
+ class MetaLemma extends TopLevelAssertion {
21
17
  constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
22
18
  super(fileContext, string, labels, suppositions, consequent, proof);
23
19
 
@@ -37,15 +33,15 @@ export default class MetaLemma extends TopLevelAssertion {
37
33
  this.fileContext.trace(`Verifying a meta-lemma...`) :
38
34
  this.fileContext.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
39
35
 
40
- const labelsVerifiedAtTopLevel = this.labels.every((label) => {
41
- const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
36
+ const labelsVerifiedWhenDeclared = this.labels.every((label) => {
37
+ const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
42
38
 
43
- if (labelVVerifiedAtTopLevel) {
39
+ if (labelVVerifiedWhenDeclared) {
44
40
  return true;
45
41
  }
46
42
  });
47
43
 
48
- if (labelsVerifiedAtTopLevel) {
44
+ if (labelsVerifiedWhenDeclared) {
49
45
  const localContext = LocalContext.fromFileContext(this.fileContext),
50
46
  suppositionsVerified = this.suppositions.every((supposition) => {
51
47
  const suppositionVerified = supposition.verify(localContext);
@@ -82,7 +78,8 @@ export default class MetaLemma extends TopLevelAssertion {
82
78
  }
83
79
 
84
80
  static fromMetaLemmaNode(metaLemmaNode, fileContext) {
85
- const proofNode = proofNodeQuery(metaLemmaNode),
81
+ const { Label, Proof, Consequent, Supposition, Substitutions } = shim,
82
+ proofNode = proofNodeQuery(metaLemmaNode),
86
83
  labelNodes = labelNodesQuery(metaLemmaNode),
87
84
  consequentNode = consequentNodeQuery(metaLemmaNode),
88
85
  suppositionNodes = suppositionNodesQuery(metaLemmaNode),
@@ -106,3 +103,8 @@ export default class MetaLemma extends TopLevelAssertion {
106
103
  }
107
104
  }
108
105
 
106
+ Object.assign(shim, {
107
+ MetaLemma
108
+ });
109
+
110
+ export default MetaLemma;
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import shim from "./shim";
4
- import Label from "./label";
5
- import Proof from "./proof";
6
- import Consequent from "./consequent";
7
- import Supposition from "./supposition";
8
4
  import LocalContext from "./context/local";
9
- import Substitutions from "./substitutions";
10
5
  import TopLevelAssertion from "./topLevelAssertion";
11
6
 
12
7
  import { nodeQuery, nodesQuery } from "./utilities/query";
@@ -43,15 +38,15 @@ class Metatheorem extends TopLevelAssertion {
43
38
 
44
39
  this.fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
45
40
 
46
- const labelsVerifiedAtTopLevel = this.labels.every((label) => {
47
- const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
41
+ const labelsVerifiedWhenDeclared = this.labels.every((label) => {
42
+ const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
48
43
 
49
- if (labelVVerifiedAtTopLevel) {
44
+ if (labelVVerifiedWhenDeclared) {
50
45
  return true;
51
46
  }
52
47
  });
53
48
 
54
- if (labelsVerifiedAtTopLevel) {
49
+ if (labelsVerifiedWhenDeclared) {
55
50
  const localContext = LocalContext.fromFileContext(this.fileContext),
56
51
  suppositionsVerified = this.suppositions.every((supposition) => {
57
52
  const suppositionVerified = supposition.verify(localContext);
@@ -117,7 +112,8 @@ class Metatheorem extends TopLevelAssertion {
117
112
  }
118
113
 
119
114
  static fromMetatheoremNode(metatheoremNode, fileContext) {
120
- const proofNode = proofNodeQuery(metatheoremNode),
115
+ const { Label, Proof, Consequent, Supposition, Substitutions } = shim,
116
+ proofNode = proofNodeQuery(metatheoremNode),
121
117
  labelNodes = labelNodesQuery(metatheoremNode),
122
118
  consequentNode = consequentNodeQuery(metatheoremNode),
123
119
  suppositionNodes = suppositionNodesQuery(metatheoremNode),
@@ -2,7 +2,6 @@
2
2
 
3
3
  import shim from "./shim";
4
4
  import LocalContext from "./context/local";
5
- import metavariableUnifier from "./unifier/metavariable";
6
5
  import FrameForMetavariableSubstitution from "./substitution/frameForMetavariable";
7
6
  import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
8
7
 
@@ -80,11 +79,11 @@ class Metavariable {
80
79
 
81
80
  localContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
82
81
 
83
- const metavariableName = this.name, ///
84
- simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableName(metavariableName);
82
+ const metavariableNode = this.node, ///
83
+ simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableNode(metavariableNode);
85
84
 
86
85
  if (simpleSubstitutionPresent) {
87
- const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableName(metavariableName),
86
+ const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode),
88
87
  substitution = simpleSubstitution, ///
89
88
  frameNodeMatches = substitution.matchFrameNode(frameNode);
90
89
 
@@ -131,14 +130,13 @@ class Metavariable {
131
130
 
132
131
  const statementNode = statement.getNode(),
133
132
  metavariableNode = this.node, ///
134
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
135
133
  substitutionNode = (substitution !== null) ?
136
134
  substitution.getSubstitutionNode() :
137
135
  null,
138
- substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode);
136
+ substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
139
137
 
140
138
  if (substitutionPresent) {
141
- const substitution = substitutions.findSubstitutionByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode),
139
+ const substitution = substitutions.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
142
140
  statementNodeMatches = substitution.matchStatementNode(statementNode);
143
141
 
144
142
  if (statementNodeMatches) {
@@ -180,8 +178,8 @@ class Metavariable {
180
178
 
181
179
  localContext.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
182
180
 
183
- const metavariableName = this.name, ///
184
- judgement = localContext.findJudgementByMetavariableName(metavariableName);
181
+ const metavariableNode = this.node, ///
182
+ judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
185
183
 
186
184
  if (judgement !== null){
187
185
  const declaration = judgement.getDeclaration();
@@ -203,18 +201,10 @@ class Metavariable {
203
201
 
204
202
  localContext.trace(`Verifying the '${metavariableString}' metavariable...`);
205
203
 
206
- const metavariableName = this.name,
207
- metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
208
-
209
- if (metavariable !== null) {
210
- const metavariableA = metavariable, ///
211
- metavariableB = this,
212
- metavariableNodeA = metavariableA.getNode(), ///
213
- metavariableNodeB = metavariableB.getNode(),
214
- metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
204
+ const metavariableNode = this.node,
205
+ metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
215
206
 
216
- verified = metavariableUnified; ///
217
- }
207
+ verified = metavariablePresent; ///
218
208
 
219
209
  if (verified) {
220
210
  localContext.debug(`...verified the '${metavariableString}' metavariable.`);
@@ -223,12 +213,12 @@ class Metavariable {
223
213
  return verified;
224
214
  }
225
215
 
226
- verifyAtTopLevel(fileContext) {
216
+ verifyWhenDeclared(fileContext) {
227
217
  let verifiedAtTopLevel = false;
228
218
 
229
219
  const metavariableString = this.string; ///
230
220
 
231
- fileContext.trace(`Verifying the '${metavariableString}' metavariable at top level...`);
221
+ fileContext.trace(`Verifying the '${metavariableString}' metavariable when declared...`);
232
222
 
233
223
  const metavariableNode = this.node, ///
234
224
  metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
@@ -262,7 +252,7 @@ class Metavariable {
262
252
  }
263
253
 
264
254
  if (verifiedAtTopLevel) {
265
- fileContext.debug(`...verified the '${metavariableString}' metavariable at top level.`);
255
+ fileContext.debug(`...verified the '${metavariableString}' metavariable when declared.`);
266
256
  }
267
257
 
268
258
  return verifiedAtTopLevel;
@@ -276,9 +266,8 @@ class Metavariable {
276
266
 
277
267
  localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
278
268
 
279
- const name = this.getName(),
280
- metavariableName = name, ///
281
- metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
269
+ const metavariableNode = this.node, ///
270
+ metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode, localContext);
282
271
 
283
272
  if (metavariable !== null) {
284
273
  const metaTypeMatches = metavariable.matchMetaType(metaType);
@@ -360,8 +349,7 @@ Object.assign(shim, {
360
349
  export default Metavariable;
361
350
 
362
351
  function metavariableFromMetavariableNode(metavariableNode, localContext) {
363
- const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
364
- metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
352
+ const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode, localContext);
365
353
 
366
354
  return metavariable;
367
355
  }
@@ -372,9 +360,7 @@ function frameMetavariableFromStatementNode(frameNode, localContext) {
372
360
  const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
373
361
 
374
362
  if (frameMetavariableNode !== null) {
375
- const frameMetavariableName = metavariableNameFromMetavariableNode(frameMetavariableNode);
376
-
377
- frameMetavariable = localContext.findMetavariableByMetavariableName(frameMetavariableName);
363
+ frameMetavariable = localContext.findMetavariableByMetavariableNode(frameMetavariableNode, localContext);
378
364
  }
379
365
 
380
366
  return frameMetavariable;
@@ -386,9 +372,7 @@ function statementMetavariableFromStatementNode(statementNode, localContext) {
386
372
  const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
387
373
 
388
374
  if (statementMetavariableNode !== null) {
389
- const statementMetavariableName = metavariableNameFromMetavariableNode(statementMetavariableNode);
390
-
391
- statementMetavariable = localContext.findMetavariableByMetavariableName(statementMetavariableName);
375
+ statementMetavariable = localContext.findMetavariableByMetavariableNode(statementMetavariableNode, localContext);
392
376
  }
393
377
 
394
378
  return statementMetavariable;
@@ -135,8 +135,7 @@ function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
135
135
 
136
136
  const reference = qualifiedStatement.getReference(),
137
137
  metavariableNode = reference.getMetavariableNode(),
138
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
139
- metavariablePresent = localContext.isMetavariablePresentByMetavariableName(metavariableName);
138
+ metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
140
139
 
141
140
  if (metavariablePresent) {
142
141
  const statement = qualifiedStatement.getStatement(),
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import Frame from "../../frame";
4
- import Equality from "../../equality";
5
- import Judgement from "../../judgement";
6
- import Declaration from "../../declaration";
7
- import Metavariable from "../../metavariable";
3
+ import shim from "../../shim";
8
4
  import TypeAssertion from "../../assertion/type";
9
5
  import DefinedAssertion from "../../assertion/defined";
10
6
  import SubproofAssertion from "../../assertion/subproof";
@@ -12,20 +8,21 @@ import ContainedAssertion from "../../assertion/contained";
12
8
 
13
9
  import { nodeQuery } from "../../utilities/query";
14
10
 
15
- const frameNodeQuery = nodeQuery("/statement/frame!"),
16
- equalityNodeQuery = nodeQuery("/statement/equality!"),
17
- judgementNodeQuery = nodeQuery("/statement/judgement!"),
18
- declarationNodeQuery = nodeQuery("/statement/declaration!"),
11
+ const frameNodeQuery = nodeQuery("/statement/frame"),
12
+ equalityNodeQuery = nodeQuery("/statement/equality"),
13
+ judgementNodeQuery = nodeQuery("/statement/judgement"),
14
+ declarationNodeQuery = nodeQuery("/statement/declaration"),
19
15
  metavariableNodeQuery = nodeQuery("/statement/metavariable!"),
20
- typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!"),
21
- definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion!"),
22
- subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
23
- containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion!");
16
+ typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion"),
17
+ definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion"),
18
+ subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion"),
19
+ containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion");
24
20
 
25
21
  function verifyAsMetavariable(statement, assignments, stated, localContext) {
26
22
  let verifiedAsMetavariable = false;
27
23
 
28
- const statementNode = statement.getNode(),
24
+ const { Metavariable } = shim,
25
+ statementNode = statement.getNode(),
29
26
  metavariableNode = metavariableNodeQuery(statementNode),
30
27
  metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
31
28
 
@@ -49,7 +46,8 @@ function verifyAsMetavariable(statement, assignments, stated, localContext) {
49
46
  function verifyAsEquality(statement, assignments, stated, localContext) {
50
47
  let verifiedAsEquality = false;
51
48
 
52
- const statementNode = statement.getNode(),
49
+ const { Equality } = shim,
50
+ statementNode = statement.getNode(),
53
51
  equalityNode = equalityNodeQuery(statementNode),
54
52
  equality = Equality.fromEqualityNode(equalityNode, localContext);
55
53
 
@@ -73,7 +71,8 @@ function verifyAsEquality(statement, assignments, stated, localContext) {
73
71
  function verifyAsFrame(statement, assignments, stated, localContext) {
74
72
  let verifiedAsFrame = false;
75
73
 
76
- const statementNode = statement.getNode(),
74
+ const { Frame } = shim,
75
+ statementNode = statement.getNode(),
77
76
  frameNode = frameNodeQuery(statementNode),
78
77
  frame = Frame.fromFrameNode(frameNode, localContext);
79
78
 
@@ -97,7 +96,8 @@ function verifyAsFrame(statement, assignments, stated, localContext) {
97
96
  function verifyAsJudgement(statement, assignments, stated, localContext) {
98
97
  let verifiedAsJudgement = false;
99
98
 
100
- const statementNode = statement.getNode(),
99
+ const { Judgement } = shim,
100
+ statementNode = statement.getNode(),
101
101
  judgementNode = judgementNodeQuery(statementNode),
102
102
  judgement = Judgement.fromJudgementNode(judgementNode, localContext);
103
103
 
@@ -121,7 +121,8 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
121
121
  function verifyAsDeclaration(statement, assignments, stated, localContext) {
122
122
  let verifiedAsDeclaration = false;
123
123
 
124
- const statementNode = statement.getNode(),
124
+ const { Declaration } = shim,
125
+ statementNode = statement.getNode(),
125
126
  declarationNode = declarationNodeQuery(statementNode),
126
127
  declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
127
128