occam-verify-cli 0.0.1089 → 0.0.1091

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 (126) hide show
  1. package/bin/action/verify.js +2 -2
  2. package/lib/assertion/contained.js +35 -41
  3. package/lib/assertion/defined.js +24 -24
  4. package/lib/assertion/subproof.js +24 -24
  5. package/lib/assertion/type.js +23 -23
  6. package/lib/assignment/equality.js +4 -10
  7. package/lib/assignment/judgement.js +4 -4
  8. package/lib/assignment/variable.js +4 -4
  9. package/lib/combinator/bracketed.js +3 -3
  10. package/lib/conclusion.js +11 -13
  11. package/lib/consequent.js +11 -13
  12. package/lib/constructor/bracketed.js +3 -3
  13. package/lib/constructor.js +2 -2
  14. package/lib/context/file.js +28 -27
  15. package/lib/context/local.js +31 -32
  16. package/lib/context/release.js +6 -3
  17. package/lib/declaration.js +18 -18
  18. package/lib/derivation.js +3 -3
  19. package/lib/equality.js +24 -24
  20. package/lib/equivalence.js +13 -13
  21. package/lib/frame.js +43 -43
  22. package/lib/index.js +2 -1
  23. package/lib/judgement.js +20 -20
  24. package/lib/label.js +9 -1
  25. package/lib/metaType.js +2 -2
  26. package/lib/metavariable.js +40 -39
  27. package/lib/mixins/statement/qualified/unify.js +19 -19
  28. package/lib/mixins/statement/resolve.js +11 -11
  29. package/lib/mixins/statement/unify.js +12 -12
  30. package/lib/mixins/statement/verify.js +36 -36
  31. package/lib/mixins/term/verify.js +2 -2
  32. package/lib/premise.js +31 -40
  33. package/lib/proof.js +6 -5
  34. package/lib/proofStep.js +17 -17
  35. package/lib/reference.js +8 -8
  36. package/lib/rule.js +21 -21
  37. package/lib/statement/qualified.js +17 -17
  38. package/lib/statement/unqualified.js +19 -19
  39. package/lib/statement.js +52 -54
  40. package/lib/subDerivation.js +3 -3
  41. package/lib/subproof.js +6 -5
  42. package/lib/substitution/frameForMetavariable.js +16 -39
  43. package/lib/substitution/statementForMetavariable.js +88 -74
  44. package/lib/substitution/termForVariable.js +15 -41
  45. package/lib/substitution.js +20 -6
  46. package/lib/substitutions.js +13 -13
  47. package/lib/supposition.js +31 -40
  48. package/lib/term.js +28 -28
  49. package/lib/topLevelAssertion.js +33 -21
  50. package/lib/unifier/equality.js +8 -8
  51. package/lib/unifier/intrinsicLevel.js +149 -0
  52. package/lib/unifier/metaLevel.js +41 -31
  53. package/lib/unifier/metavariable.js +14 -8
  54. package/lib/unifier/statementWithCombinator.js +16 -16
  55. package/lib/unifier/termWithConstructor.js +6 -6
  56. package/lib/unifier.js +47 -47
  57. package/lib/utilities/assignments.js +3 -3
  58. package/lib/utilities/equivalences.js +14 -14
  59. package/lib/utilities/json.js +22 -21
  60. package/lib/utilities/unifier.js +7 -8
  61. package/lib/variable.js +33 -33
  62. package/lib/verifier/statementAsCombinator.js +2 -2
  63. package/lib/verifier/termAsConstructor.js +2 -2
  64. package/package.json +2 -2
  65. package/src/assertion/contained.js +37 -45
  66. package/src/assertion/defined.js +25 -25
  67. package/src/assertion/subproof.js +25 -28
  68. package/src/assertion/type.js +23 -23
  69. package/src/assignment/equality.js +4 -6
  70. package/src/assignment/judgement.js +4 -4
  71. package/src/assignment/variable.js +4 -4
  72. package/src/combinator/bracketed.js +2 -2
  73. package/src/conclusion.js +14 -15
  74. package/src/consequent.js +14 -15
  75. package/src/constructor/bracketed.js +2 -2
  76. package/src/constructor.js +3 -2
  77. package/src/context/file.js +26 -25
  78. package/src/context/local.js +21 -23
  79. package/src/context/release.js +5 -3
  80. package/src/declaration.js +20 -20
  81. package/src/derivation.js +2 -2
  82. package/src/equality.js +26 -26
  83. package/src/equivalence.js +12 -12
  84. package/src/frame.js +42 -42
  85. package/src/index.js +1 -0
  86. package/src/judgement.js +25 -25
  87. package/src/label.js +14 -0
  88. package/src/metaType.js +1 -1
  89. package/src/metavariable.js +51 -43
  90. package/src/mixins/statement/qualified/unify.js +21 -21
  91. package/src/mixins/statement/resolve.js +12 -12
  92. package/src/mixins/statement/unify.js +11 -11
  93. package/src/mixins/statement/verify.js +35 -35
  94. package/src/mixins/term/verify.js +1 -1
  95. package/src/premise.js +42 -53
  96. package/src/proof.js +6 -4
  97. package/src/proofStep.js +21 -21
  98. package/src/reference.js +12 -11
  99. package/src/rule.js +20 -20
  100. package/src/statement/qualified.js +18 -17
  101. package/src/statement/unqualified.js +19 -18
  102. package/src/statement.js +63 -66
  103. package/src/subDerivation.js +2 -3
  104. package/src/subproof.js +6 -4
  105. package/src/substitution/frameForMetavariable.js +29 -45
  106. package/src/substitution/statementForMetavariable.js +136 -86
  107. package/src/substitution/termForVariable.js +28 -49
  108. package/src/substitution.js +15 -5
  109. package/src/substitutions.js +12 -12
  110. package/src/supposition.js +41 -53
  111. package/src/term.js +27 -27
  112. package/src/topLevelAssertion.js +32 -19
  113. package/src/unifier/equality.js +7 -7
  114. package/src/unifier/intrinsicLevel.js +61 -0
  115. package/src/unifier/metaLevel.js +60 -46
  116. package/src/unifier/metavariable.js +22 -13
  117. package/src/unifier/statementWithCombinator.js +28 -28
  118. package/src/unifier/termWithConstructor.js +8 -8
  119. package/src/unifier.js +55 -55
  120. package/src/utilities/assignments.js +2 -2
  121. package/src/utilities/equivalences.js +13 -13
  122. package/src/utilities/json.js +76 -66
  123. package/src/utilities/unifier.js +10 -12
  124. package/src/variable.js +43 -40
  125. package/src/verifier/statementAsCombinator.js +2 -1
  126. package/src/verifier/termAsConstructor.js +2 -1
@@ -29,23 +29,23 @@ export default class TypeAssertion {
29
29
  return this.type;
30
30
  }
31
31
 
32
- verify(assignments, stated, localContext) {
32
+ verify(assignments, stated, context) {
33
33
  let verified = false;
34
34
 
35
35
  let typeAssertionString = this.string; ///
36
36
 
37
- localContext.trace(`Verifying the '${typeAssertionString}' type assertion...`);
37
+ context.trace(`Verifying the '${typeAssertionString}' type assertion...`);
38
38
 
39
- const typeVerified = this.verifyType(localContext);
39
+ const typeVerified = this.verifyType(context);
40
40
 
41
41
  if (typeVerified) {
42
42
  let verifiedWhenStated = false,
43
43
  verifiedWhenDerived = false;
44
44
 
45
45
  if (stated) {
46
- verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
46
+ verifiedWhenStated = this.verifyWhenStated(assignments, context);
47
47
  } else {
48
- verifiedWhenDerived = this.verifyWhenDerived(localContext);
48
+ verifiedWhenDerived = this.verifyWhenDerived(context);
49
49
  }
50
50
 
51
51
  if (verifiedWhenStated || verifiedWhenDerived) {
@@ -54,13 +54,13 @@ export default class TypeAssertion {
54
54
  }
55
55
 
56
56
  if (verified) {
57
- localContext.debug(`...verified the '${typeAssertionString}' type assertion.`);
57
+ context.debug(`...verified the '${typeAssertionString}' type assertion.`);
58
58
  }
59
59
 
60
60
  return verified;
61
61
  }
62
62
 
63
- verifyType(localContext) {
63
+ verifyType(context) {
64
64
  let typeVerified;
65
65
 
66
66
  if (this.type === objectType) {
@@ -68,34 +68,34 @@ export default class TypeAssertion {
68
68
  } else {
69
69
  const typeName = this.type.getName();
70
70
 
71
- localContext.trace(`Verifying the '${typeName}' type...`);
71
+ context.trace(`Verifying the '${typeName}' type...`);
72
72
 
73
- const type = localContext.findTypeByTypeName(typeName);
73
+ const type = context.findTypeByTypeName(typeName);
74
74
 
75
75
  if (type !== null) {
76
76
  this.type = type;
77
77
 
78
78
  typeVerified = true;
79
79
  } else {
80
- localContext.debug(`The '${typeName}' type is missing.`);
80
+ context.debug(`The '${typeName}' type is missing.`);
81
81
  }
82
82
 
83
83
  if (typeVerified) {
84
- localContext.debug(`...verified the '${typeName}' type.`);
84
+ context.debug(`...verified the '${typeName}' type.`);
85
85
  }
86
86
  }
87
87
 
88
88
  return typeVerified;
89
89
  }
90
90
 
91
- verifyWhenStated(assignments, localContext) {
91
+ verifyWhenStated(assignments, context) {
92
92
  let verifiedWhenStated = false;
93
93
 
94
94
  const typeAssertionString = this.string; ///
95
95
 
96
- localContext.trace(`Verifying the '${typeAssertionString}' stated type assertion...`);
96
+ context.trace(`Verifying the '${typeAssertionString}' stated type assertion...`);
97
97
 
98
- const termVerified = this.term.verify(localContext, () => {
98
+ const termVerified = this.term.verify(context, () => {
99
99
  let verifiedAhead;
100
100
 
101
101
  const termType = this.term.getType(),
@@ -113,7 +113,7 @@ export default class TypeAssertion {
113
113
  const { Variable } = shim,
114
114
  termNode = this.term.getNode(),
115
115
  variableNode = variableNodeQuery(termNode),
116
- variable = Variable.fromVariableNodeAndType(variableNode, this.type, localContext);
116
+ variable = Variable.fromVariableNodeAndType(variableNode, this.type, context);
117
117
 
118
118
  if (variable !== null) {
119
119
  const variableAssignment = VariableAssignment.fromVariable(variable),
@@ -127,20 +127,20 @@ export default class TypeAssertion {
127
127
  }
128
128
 
129
129
  if (verifiedWhenStated) {
130
- localContext.debug(`...verified the '${typeAssertionString}' stated type assertion.`);
130
+ context.debug(`...verified the '${typeAssertionString}' stated type assertion.`);
131
131
  }
132
132
 
133
133
  return verifiedWhenStated;
134
134
  }
135
135
 
136
- verifyWhenDerived(localContext) {
136
+ verifyWhenDerived(context) {
137
137
  let verifiedWhenDerived;
138
138
 
139
139
  const typeAssertionString = this.string; ///
140
140
 
141
- localContext.trace(`Verifying the '${typeAssertionString}' derived type assertion...`);
141
+ context.trace(`Verifying the '${typeAssertionString}' derived type assertion...`);
142
142
 
143
- const termVerified = this.term.verify(localContext, () => {
143
+ const termVerified = this.term.verify(context, () => {
144
144
  let verifiedAhead;
145
145
 
146
146
  const termType = this.term.getType(),
@@ -154,21 +154,21 @@ export default class TypeAssertion {
154
154
  verifiedWhenDerived = termVerified; ///
155
155
 
156
156
  if (verifiedWhenDerived) {
157
- localContext.debug(`...verified the '${typeAssertionString}' derived type assertion.`);
157
+ context.debug(`...verified the '${typeAssertionString}' derived type assertion.`);
158
158
  }
159
159
 
160
160
  return verifiedWhenDerived;
161
161
  }
162
162
 
163
- static fromTypeAssertionNode(typeAssertionNode, localContext) {
163
+ static fromTypeAssertionNode(typeAssertionNode, context) {
164
164
  let typeAssertion = null;
165
165
 
166
166
  if (typeAssertionNode !== null) {
167
167
  const { Term, Type } = shim,
168
168
  termNode = termNodeQuery(typeAssertionNode),
169
169
  typeNode = typeNodeQuery(typeAssertionNode),
170
- term = Term.fromTermNode(termNode, localContext),
171
- type = Type.fromTypeNode(typeNode, localContext),
170
+ term = Term.fromTermNode(termNode, context),
171
+ type = Type.fromTypeNode(typeNode, context),
172
172
  string = stringFromTermAndType(term, type);
173
173
 
174
174
  typeAssertion = new TypeAssertion(string, term, type);
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import local from "../context/local";
4
-
5
3
  export default class EqualityAssignment {
6
4
  constructor(equality) {
7
5
  this.equality = equality;
@@ -11,14 +9,14 @@ export default class EqualityAssignment {
11
9
  return this.equality;
12
10
  }
13
11
 
14
- assign(localContext) {
15
- const equalityAdded = localContext.addEquality(this.equality, localContext),
12
+ assign(context) {
13
+ const equalityAdded = context.addEquality(this.equality, context),
16
14
  equalityString = this.equality.getString(),
17
15
  equalityAssigned = equalityAdded; ///
18
16
 
19
17
  equalityAssigned ?
20
- localContext.trace(`Assigned the '${equalityString}' equality.`) :
21
- localContext.debug(`Unable to assign the '${equalityString}' equality.`);
18
+ context.trace(`Assigned the '${equalityString}' equality.`) :
19
+ context.debug(`Unable to assign the '${equalityString}' equality.`);
22
20
 
23
21
  return equalityAssigned;
24
22
  }
@@ -9,14 +9,14 @@ export default class JudgementAssignment {
9
9
  return this.judgement;
10
10
  }
11
11
 
12
- assign(localContext) {
13
- const judgementAdded = localContext.addJudgement(this.judgement),
12
+ assign(context) {
13
+ const judgementAdded = context.addJudgement(this.judgement),
14
14
  judgementString = this.judgement.getString(),
15
15
  judgementAssigned = judgementAdded; ///
16
16
 
17
17
  judgementAssigned ?
18
- localContext.trace(`Assigned the '${judgementString}' judgement.`) :
19
- localContext.debug(`Unable to assign the '${judgementString}' judgement.`);
18
+ context.trace(`Assigned the '${judgementString}' judgement.`) :
19
+ context.debug(`Unable to assign the '${judgementString}' judgement.`);
20
20
 
21
21
  return judgementAssigned;
22
22
  }
@@ -9,17 +9,17 @@ export default class VariableAssignment {
9
9
  return this.variable;
10
10
  }
11
11
 
12
- assign(localContext) {
12
+ assign(context) {
13
13
  const nested = false,
14
- variableAdded = localContext.addVariable(this.variable, nested),
14
+ variableAdded = context.addVariable(this.variable, nested),
15
15
  variableType = this.variable.getType(),
16
16
  variableString = this.variable.getString(),
17
17
  variableTypeName = variableType.getName(),
18
18
  variableAssigned = variableAdded; ///
19
19
 
20
20
  variableAssigned ?
21
- localContext.trace(`Assigned the '${variableString}' variable with type '${variableTypeName}'.`) :
22
- localContext.debug(`Unable to assign the '${variableString}' variable with type '${variableTypeName}'.`);
21
+ context.trace(`Assigned the '${variableString}' variable with type '${variableTypeName}'.`) :
22
+ context.debug(`Unable to assign the '${variableString}' variable with type '${variableTypeName}'.`);
23
23
 
24
24
  return variableAssigned;
25
25
  }
@@ -33,7 +33,7 @@ const lexer = nominalLexer, ///
33
33
 
34
34
  return string;
35
35
  },
36
- localContext = {
36
+ context = {
37
37
  nodeAsTokens,
38
38
  nodeAsString,
39
39
  tokensAsString
@@ -44,7 +44,7 @@ export const bracketedStatementNode = statementNode; ///
44
44
  export default class BracketedCombinator extends Combinator {
45
45
  static fromNothing() {
46
46
  const { Statement } = shim,
47
- statement = Statement.fromStatementNode(statementNode, localContext),
47
+ statement = Statement.fromStatementNode(statementNode, context),
48
48
  bracketedCombinator = new BracketedCombinator(statement);
49
49
 
50
50
  return bracketedCombinator;
package/src/conclusion.js CHANGED
@@ -26,46 +26,45 @@ class Conclusion {
26
26
 
27
27
  getStatement() { return this.unqualifiedStatement.getStatement(); }
28
28
 
29
- unifyStatement(statement, substitutions, localContext) {
29
+ unifyStatement(statement, substitutions, context) {
30
30
  let statementUnified;
31
31
 
32
- const statementString = statement.getString(),
33
- conclusionString = this.getString();
32
+ const localContext = LocalContext.fromFileContext(this.fileContext),
33
+ generalContext = localContext, ///
34
+ specificContext = context; ///
34
35
 
35
- const localContextB = localContext; ///
36
+ const conclusion = this, ///
37
+ statementString = statement.getString(),
38
+ conclusionString = conclusion.getString();
36
39
 
37
- localContext = LocalContext.fromFileContext(this.fileContext);
40
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${conclusionString}' conclusion...`);
38
41
 
39
- const localContextA = localContext; ///
40
-
41
- localContextB.trace(`Unifying the '${statementString}' statement with the '${conclusionString}' conclusion...`);
42
-
43
- statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
42
+ statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, generalContext, specificContext);
44
43
 
45
44
  if (statementUnified) {
46
- localContextB.debug(`...unified the '${statementString}' statement with the '${conclusionString}' conclusion.`);
45
+ specificContext.debug(`...unified the '${statementString}' statement with the '${conclusionString}' conclusion.`);
47
46
  }
48
47
 
49
48
  return statementUnified;
50
49
  }
51
50
 
52
- verify(localContext) {
51
+ verify(context) {
53
52
  let verified = false;
54
53
 
55
54
  const conclusionString = this.getString(); ///
56
55
 
57
- localContext.trace(`Verifying the '${conclusionString}' conclusion...`);
56
+ context.trace(`Verifying the '${conclusionString}' conclusion...`);
58
57
 
59
58
  const stated = true,
60
59
  assignments = [],
61
- unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
60
+ unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, context);
62
61
 
63
62
  if (unqualifiedStatementVerified) {
64
63
  verified = true;
65
64
  }
66
65
 
67
66
  if (verified) {
68
- localContext.debug(`...verified the '${conclusionString}' conclusion.`);
67
+ context.debug(`...verified the '${conclusionString}' conclusion.`);
69
68
  }
70
69
 
71
70
  return verified;
package/src/consequent.js CHANGED
@@ -26,46 +26,45 @@ class Consequent {
26
26
 
27
27
  getStatement() { return this.unqualifiedStatement.getStatement(); }
28
28
 
29
- unifyStatement(statement, substitutions, localContext) {
29
+ unifyStatement(statement, substitutions, context) {
30
30
  let statementUnified;
31
31
 
32
- const statementString = statement.getString(),
33
- consequentString = this.getString();
32
+ const localContext = LocalContext.fromFileContext(this.fileContext),
33
+ generalContext = localContext, ///
34
+ specificContext = context; ///
34
35
 
35
- const localContextB = localContext; ///
36
+ const consequent = this, ///
37
+ statementString = statement.getString(),
38
+ consequentString = consequent.getString();
36
39
 
37
- localContext = LocalContext.fromFileContext(this.fileContext);
40
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${consequentString}' consequent...`);
38
41
 
39
- const localContextA = localContext; ///
40
-
41
- localContextB.trace(`Unifying the '${statementString}' statement with the '${consequentString}' consequent...`);
42
-
43
- statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
42
+ statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, generalContext, specificContext);
44
43
 
45
44
  if (statementUnified) {
46
- localContextB.debug(`...unified the '${statementString}' statement with the '${consequentString}' consequent.`);
45
+ specificContext.debug(`...unified the '${statementString}' statement with the '${consequentString}' consequent.`);
47
46
  }
48
47
 
49
48
  return statementUnified;
50
49
  }
51
50
 
52
- verify(localContext) {
51
+ verify(context) {
53
52
  let verified = false;
54
53
 
55
54
  const consequentString = this.getString(); ///
56
55
 
57
- localContext.trace(`Verifying the '${consequentString}' consequent...`);
56
+ context.trace(`Verifying the '${consequentString}' consequent...`);
58
57
 
59
58
  const stated = true,
60
59
  assignments = [],
61
- unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
60
+ unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, context);
62
61
 
63
62
  if (unqualifiedStatementVerified) {
64
63
  verified = true;
65
64
  }
66
65
 
67
66
  if (verified) {
68
- localContext.debug(`...verified the '${consequentString}' consequent.`);
67
+ context.debug(`...verified the '${consequentString}' consequent.`);
69
68
  }
70
69
 
71
70
  return verified;
@@ -34,7 +34,7 @@ const lexer = nominalLexer, ///
34
34
 
35
35
  return string;
36
36
  },
37
- localContext = {
37
+ context = {
38
38
  nodeAsTokens,
39
39
  nodeAsString,
40
40
  tokensAsString
@@ -45,7 +45,7 @@ export const bracketedTermNode = termNode; ///
45
45
  export default class BracketedConstructor extends Constructor {
46
46
  static fromNothing() {
47
47
  const { Term } = shim,
48
- term = Term.fromTermNode(termNode, localContext),
48
+ term = Term.fromTermNode(termNode, context),
49
49
  type = null,
50
50
  string = stringFromTermAndType(term, type),
51
51
  bracketedConstructor = new BracketedConstructor(string, term);
@@ -68,9 +68,10 @@ class Constructor {
68
68
  const { Term, Type } = shim,
69
69
  termNode = termNodeQuery(constructorDeclarationNode),
70
70
  typeNode = typeNodeQuery(constructorDeclarationNode),
71
- type = Type.fromTypeNode(typeNode),
72
71
  localContext = LocalContext.fromFileContext(fileContext),
73
- term = Term.fromTermNodeAndType(termNode, type, localContext),
72
+ context = localContext, ///
73
+ type = Type.fromTypeNode(typeNode),
74
+ term = Term.fromTermNodeAndType(termNode, type, context),
74
75
  string = stringFromTermAndType(term, type),
75
76
  constructor = new Constructor(string, term);
76
77
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
+ import LocalContext from "./local";
5
6
  import metavariableUnifier from "../unifier/metavariable";
6
7
 
7
8
  import { objectType } from "../type";
@@ -29,6 +30,7 @@ import { typesFromJSON,
29
30
  constructorsToConstructorsJSON,
30
31
  metatheoremsToMetatheoremsJSON,
31
32
  metavariablesToMetavariablesJSON } from "../utilities/json";
33
+ import local from "./local";
32
34
 
33
35
  const { push } = arrayUtilities;
34
36
 
@@ -396,8 +398,8 @@ export default class FileContext {
396
398
  return metavariablePresent;
397
399
  }
398
400
 
399
- isMetavariablePresentByMetavariableNode(metavariableNode, localContext) {
400
- const metavariable = this.findMetavariableByMetavariableNode(metavariableNode, localContext),
401
+ isMetavariablePresentByMetavariableNode(metavariableNode, specificContext) {
402
+ const metavariable = this.findMetavariableByMetavariableNode(metavariableNode, specificContext),
401
403
  metavariablePresent = (metavariable !== null);
402
404
 
403
405
  return metavariablePresent;
@@ -459,41 +461,39 @@ export default class FileContext {
459
461
  return theorem;
460
462
  }
461
463
 
462
- findMetaLemmaByReference(reference) {
463
- const metaLemmas = this.getMetaLemmas(),
464
+ findConjectureByReference(reference) {
465
+ const conjectures = this.getConjectures(),
464
466
  metavariableNode = reference.getMetavariableNode(),
465
- metaLemma = metaLemmas.find((metaLemma) => {
466
- const metavariableNodeMatches = metaLemma.matchMetavariableNode(metavariableNode);
467
+ conjecture = conjectures.find((conjecture) => {
468
+ const metavariableNodeMatches = conjecture.matchMetavariableNode(metavariableNode);
467
469
 
468
470
  if (metavariableNodeMatches) {
469
471
  return true;
470
472
  }
471
473
  }) || null;
472
474
 
473
- return metaLemma;
475
+ return conjecture;
474
476
  }
475
477
 
476
- findConjectureByReference(reference) {
477
- const conjectures = this.getConjectures(),
478
- metavariableNode = reference.getMetavariableNode(),
479
- conjecture = conjectures.find((conjecture) => {
480
- const metavariableNodeMatches = conjecture.matchMetavariableNode(metavariableNode);
478
+ findMetaLemmaByReference(reference, specificContext) {
479
+ const metaLemmas = this.getMetaLemmas(),
480
+ metaLemma = metaLemmas.find((metaLemma) => {
481
+ const referenceUnified = metaLemma.unifyReference(reference, specificContext);
481
482
 
482
- if (metavariableNodeMatches) {
483
+ if (referenceUnified) {
483
484
  return true;
484
485
  }
485
486
  }) || null;
486
487
 
487
- return conjecture;
488
+ return metaLemma;
488
489
  }
489
490
 
490
- findMetatheoremByReference(reference) {
491
+ findMetatheoremByReference(reference, specificContext) {
491
492
  const metatheorems = this.getMetatheorems(),
492
- metavariableNode = reference.getMetavariableNode(),
493
493
  metatheorem = metatheorems.find((metatheorem) => {
494
- const metavariableNodeMatches = metatheorem.matchMetavariableNode(metavariableNode);
494
+ const referenceUnified = metatheorem.unifyReference(reference, specificContext);
495
495
 
496
- if (metavariableNodeMatches) {
496
+ if (referenceUnified) {
497
497
  return true;
498
498
  }
499
499
  }) || null;
@@ -541,13 +541,14 @@ export default class FileContext {
541
541
  return metavariable;
542
542
  }
543
543
 
544
- findMetavariableByMetavariableNode(metavariableNode, localContext) {
544
+ findMetavariableByMetavariableNode(metavariableNode, specificContext) {
545
545
  const metavariableNodeB = metavariableNode, ///
546
+ generalContext = this, ///
546
547
  metavariables = this.getMetavariables(),
547
548
  metavariable = metavariables.find((metavariable) => {
548
549
  const metavariableA = metavariable, ///
549
550
  metavariableNodeA = metavariableA.getNode(), ///
550
- metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
551
+ metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, generalContext, specificContext);
551
552
 
552
553
  if (metavariableUnified) {
553
554
  return true;
@@ -585,15 +586,15 @@ export default class FileContext {
585
586
  return conjecturePresent;
586
587
  }
587
588
 
588
- isMetaLemmaPresentByReference(reference) {
589
- const metaLemma = this.findMetaLemmaByReference(reference),
589
+ isMetaLemmaPresentByReference(reference, specificContext) {
590
+ const metaLemma = this.findMetaLemmaByReference(reference, specificContext),
590
591
  metaLemmaPresent = (metaLemma !== null);
591
592
 
592
593
  return metaLemmaPresent;
593
594
  }
594
595
 
595
- isMetatheoremPresentByReference(reference) {
596
- const metatheorem = this.findMetatheoremByReference(reference),
596
+ isMetatheoremPresentByReference(reference, specificContext) {
597
+ const metatheorem = this.findMetatheoremByReference(reference, specificContext),
597
598
  metatheoremPresent = (metatheorem !== null);
598
599
 
599
600
  return metatheoremPresent;
@@ -729,7 +730,7 @@ export default class FileContext {
729
730
  this.metavariables = metavariablesFromJSON(json, fileContext);
730
731
  }
731
732
 
732
- reset() {
733
+ clear() {
733
734
  this.types = [];
734
735
  this.rules = [];
735
736
  this.axioms = [];
@@ -105,7 +105,7 @@ class LocalContext {
105
105
 
106
106
  getConstructors() { return this.context.getConstructors(); }
107
107
 
108
- addEquality(equality, localContext) {
108
+ addEquality(equality, context) {
109
109
  let equalityAdded;
110
110
 
111
111
  const equalityReflexive = equality.isReflexive();
@@ -123,15 +123,15 @@ class LocalContext {
123
123
  } else if ((leftEquivalence === null) && (rightEquivalence === null)) {
124
124
  const equivalence = Equivalence.fromLeftTermAndRightTerm(leftTerm, rightTerm);
125
125
 
126
- this.addEquivalence(equivalence, localContext);
126
+ this.addEquivalence(equivalence, context);
127
127
 
128
128
  equalityAdded = true;
129
129
  } else if ((leftEquivalence !== null) && (rightEquivalence === null)) {
130
- leftEquivalence.addTerm(rightTerm, localContext);
130
+ leftEquivalence.addTerm(rightTerm, context);
131
131
 
132
132
  equalityAdded = true;
133
133
  } else if ((leftEquivalence === null) && (rightEquivalence !== null)) {
134
- rightEquivalence.addTerm(leftTerm, localContext);
134
+ rightEquivalence.addTerm(leftTerm, context);
135
135
 
136
136
  equalityAdded = true;
137
137
  } else if ((leftEquivalence !== null) && (rightEquivalence !== null)) {
@@ -149,9 +149,9 @@ class LocalContext {
149
149
  this.addEquivalence(equivalence);
150
150
  }
151
151
 
152
- equivalence.addTerm(leftTerm, localContext);
152
+ equivalence.addTerm(leftTerm, context);
153
153
 
154
- equivalence.addTerm(rightTerm, localContext);
154
+ equivalence.addTerm(rightTerm, context);
155
155
 
156
156
  equalityAdded = true;
157
157
  }
@@ -179,10 +179,10 @@ class LocalContext {
179
179
  this.proofSteps.push(proofStep);
180
180
  }
181
181
 
182
- addEquivalence(equivalence, localContext) {
182
+ addEquivalence(equivalence, context) {
183
183
  const equivalenceString = equivalence.asString();
184
184
 
185
- localContext.trace(`Added the '${equivalenceString}' equivalence.`);
185
+ context.trace(`Added the '${equivalenceString}' equivalence.`);
186
186
 
187
187
  this.equivalences.push(equivalence);
188
188
  }
@@ -273,7 +273,7 @@ class LocalContext {
273
273
 
274
274
  isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
275
275
 
276
- isMetavariablePresentByMetavariableNode(metavariableNode, localContext) { return this.context.isMetavariablePresentByMetavariableNode(metavariableNode, localContext); }
276
+ isMetavariablePresentByMetavariableNode(metavariableNode, specificContext) { return this.context.isMetavariablePresentByMetavariableNode(metavariableNode, specificContext); }
277
277
 
278
278
  isVariablePresentByVariableName(variableName, nested = true) {
279
279
  const variable = this.findVariableByVariableName(variableName, nested),
@@ -300,7 +300,7 @@ class LocalContext {
300
300
 
301
301
  findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
302
302
 
303
- findMetavariableByMetavariableNode(metavariableNode, localContext) { return this.context.findMetavariableByMetavariableNode(metavariableNode, localContext); }
303
+ findMetavariableByMetavariableNode(metavariableNode, specificContext) { return this.context.findMetavariableByMetavariableNode(metavariableNode, specificContext); }
304
304
 
305
305
  findVariableByVariableName(variableName, nested = true) {
306
306
  const variables = this.getVariables(nested),
@@ -338,11 +338,11 @@ class LocalContext {
338
338
 
339
339
  findTheoremByReference(reference) { return this.context.findTheoremByReference(reference); }
340
340
 
341
- findMetaLemmaByReference(reference) { return this.context.findMetaLemmaByReference(reference); }
342
-
343
341
  findConjectureByReference(reference) { return this.context.findConjectureByReference(reference); }
344
342
 
345
- findMetatheoremByReference(reference) { return this.context.findMetatheoremByReference(reference); }
343
+ findMetaLemmaByReference(reference, specificContext) { return this.context.findMetaLemmaByReference(reference, specificContext); }
344
+
345
+ findMetatheoremByReference(reference, specificContext) { return this.context.findMetatheoremByReference(reference, specificContext); }
346
346
 
347
347
  isAxiomPresentByReference(reference) { return this.context.isAxiomPresentByReference(reference); }
348
348
 
@@ -352,9 +352,9 @@ class LocalContext {
352
352
 
353
353
  isConjecturePresentByReference(reference) { return this.context.isConjecturePresentByReference(reference); }
354
354
 
355
- isMetaLemmaPresentByReference(reference) { return this.context.isMetaLemmaPresentByReference(reference); }
355
+ isMetaLemmaPresentByReference(reference, specificContext) { return this.context.isMetaLemmaPresentByReference(reference, specificContext); }
356
356
 
357
- isMetatheoremPresentByReference(reference) { return this.context.isMetatheoremPresentByReference(reference); }
357
+ isMetatheoremPresentByReference(reference, specificContext) { return this.context.isMetatheoremPresentByReference(reference, specificContext); }
358
358
 
359
359
  nodeAsString(node, tokens = null) {
360
360
  if (tokens === null) {
@@ -408,9 +408,8 @@ class LocalContext {
408
408
 
409
409
  error(message, node) { this.context.error(message, node); }
410
410
 
411
- static fromFileContext(fileContext) {
412
- const context = fileContext, ///
413
- tokens = null,
411
+ static fromContext(context) {
412
+ const tokens = null,
414
413
  variables = [],
415
414
  proofSteps = [],
416
415
  judgements = [],
@@ -420,15 +419,14 @@ class LocalContext {
420
419
  return localContext;
421
420
  }
422
421
 
423
- static fromLocalContext(localContext) {
424
- const context = localContext, ///
422
+ static fromFileContext(fileContext) {
423
+ const context = fileContext, ///
425
424
  tokens = null,
426
425
  variables = [],
427
426
  proofSteps = [],
428
427
  judgements = [],
429
- equivalences = [];
430
-
431
- localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences); ///
428
+ equivalences = [],
429
+ localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences);
432
430
 
433
431
  return localContext;
434
432
  }
@@ -510,11 +510,13 @@ function verifyFileContext(fileContext) {
510
510
  if (node !== null) {
511
511
  fileContext.debug(`Verifying the '${filePath}' file...`);
512
512
 
513
- fileContext.reset();
514
-
515
513
  const verifiedAtTopLevel = topLevelVerifier.verify(node, fileContext);
516
514
 
517
- fileContextVerified = verifiedAtTopLevel; ///
515
+ if (verifiedAtTopLevel) {
516
+ fileContextVerified = true;
517
+ } else {
518
+ fileContext.clear();
519
+ }
518
520
 
519
521
  if (fileContextVerified) {
520
522
  fileContext.info(`...verified the '${filePath}' file.`);