occam-verify-cli 0.0.922 → 0.0.924

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 (150) hide show
  1. package/lib/axiom.js +9 -9
  2. package/lib/conclusion.js +11 -41
  3. package/lib/conjecture.js +9 -9
  4. package/lib/constants.js +1 -13
  5. package/lib/context/file.js +3 -3
  6. package/lib/context/local.js +19 -59
  7. package/lib/declaration.js +15 -15
  8. package/lib/lemma.js +9 -9
  9. package/lib/metaLemma.js +7 -7
  10. package/lib/metatheorem.js +7 -7
  11. package/lib/metavariable.js +8 -1
  12. package/lib/mixins/nodesVerifier/metaLevel.js +6 -6
  13. package/lib/premise.js +14 -91
  14. package/lib/{step/proof.js → proofStep.js} +1 -1
  15. package/lib/rule.js +1 -45
  16. package/lib/ruleNames.js +1 -9
  17. package/lib/substitution/statementForMetavariable.js +9 -1
  18. package/lib/substitution.js +1 -8
  19. package/lib/supposition.js +55 -1
  20. package/lib/theorem.js +9 -9
  21. package/lib/topLevelAssertion.js +186 -0
  22. package/lib/utilities/customGrammar.js +2 -2
  23. package/lib/utilities/match.js +13 -50
  24. package/lib/utilities/node.js +2 -27
  25. package/lib/utilities/tokens.js +1 -8
  26. package/lib/utilities/verify.js +8 -24
  27. package/lib/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +29 -29
  28. package/lib/verifier/nodes/metaLevel.js +13 -13
  29. package/lib/verify/axiom.js +4 -4
  30. package/lib/verify/conclusion.js +10 -11
  31. package/lib/verify/conjecture.js +4 -4
  32. package/lib/verify/containedAssertion.js +91 -0
  33. package/lib/verify/declaration.js +7 -7
  34. package/lib/verify/definedAssertion.js +115 -0
  35. package/lib/verify/derivation.js +7 -7
  36. package/lib/verify/frame.js +2 -2
  37. package/lib/verify/judgement.js +2 -2
  38. package/lib/verify/lemma.js +5 -5
  39. package/lib/verify/metaLemma.js +12 -12
  40. package/lib/verify/metastatement.js +48 -67
  41. package/lib/verify/metatheorem.js +12 -12
  42. package/lib/verify/metavariable.js +2 -2
  43. package/lib/verify/premise.js +11 -30
  44. package/lib/verify/proof.js +3 -3
  45. package/lib/verify/proofStep.js +8 -8
  46. package/lib/verify/rule.js +10 -10
  47. package/lib/verify/statement/qualified.js +38 -15
  48. package/lib/verify/statement/unqualified.js +38 -10
  49. package/lib/verify/statement.js +85 -92
  50. package/lib/verify/subDerivation.js +3 -3
  51. package/lib/verify/subproof.js +3 -3
  52. package/lib/verify/supposition.js +3 -3
  53. package/lib/verify/termAsConstructor.js +2 -2
  54. package/lib/verify/theorem.js +4 -4
  55. package/package.json +2 -2
  56. package/src/axiom.js +4 -4
  57. package/src/conclusion.js +13 -52
  58. package/src/conjecture.js +4 -4
  59. package/src/constants.js +0 -3
  60. package/src/context/file.js +2 -2
  61. package/src/context/local.js +21 -67
  62. package/src/declaration.js +19 -19
  63. package/src/lemma.js +4 -4
  64. package/src/metaLemma.js +4 -4
  65. package/src/metatheorem.js +4 -4
  66. package/src/metavariable.js +6 -0
  67. package/src/mixins/nodesVerifier/metaLevel.js +8 -8
  68. package/src/premise.js +20 -137
  69. package/src/rule.js +0 -67
  70. package/src/ruleNames.js +0 -2
  71. package/src/substitution/statementForMetavariable.js +14 -0
  72. package/src/substitution.js +0 -6
  73. package/src/supposition.js +46 -0
  74. package/src/theorem.js +4 -4
  75. package/src/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +36 -23
  76. package/src/utilities/customGrammar.js +1 -2
  77. package/src/utilities/match.js +13 -60
  78. package/src/utilities/node.js +3 -32
  79. package/src/utilities/tokens.js +0 -8
  80. package/src/utilities/verify.js +4 -20
  81. package/src/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +36 -37
  82. package/src/verifier/nodes/metaLevel.js +17 -17
  83. package/src/verify/axiom.js +5 -4
  84. package/src/verify/conclusion.js +9 -13
  85. package/src/verify/conjecture.js +5 -4
  86. package/src/verify/{statementAsContainedAssertion.js → containedAssertion.js} +20 -36
  87. package/src/verify/declaration.js +8 -8
  88. package/src/verify/{statementAsDefinedAssertion.js → definedAssertion.js} +22 -37
  89. package/src/verify/derivation.js +6 -6
  90. package/src/verify/frame.js +1 -1
  91. package/src/verify/judgement.js +1 -1
  92. package/src/verify/lemma.js +8 -5
  93. package/src/verify/metaLemma.js +24 -24
  94. package/src/verify/metastatement.js +48 -76
  95. package/src/verify/metatheorem.js +23 -23
  96. package/src/verify/metavariable.js +1 -1
  97. package/src/verify/premise.js +14 -46
  98. package/src/verify/proof.js +2 -2
  99. package/src/verify/proofStep.js +4 -4
  100. package/src/verify/rule.js +11 -11
  101. package/src/verify/statement/qualified.js +56 -21
  102. package/src/verify/statement/unqualified.js +52 -10
  103. package/src/verify/statement.js +133 -39
  104. package/src/verify/subDerivation.js +2 -2
  105. package/src/verify/subproof.js +2 -2
  106. package/src/verify/supposition.js +1 -1
  107. package/src/verify/termAsConstructor.js +2 -2
  108. package/src/verify/theorem.js +7 -4
  109. package/lib/axiomLemmaTheoremConjecture.js +0 -174
  110. package/lib/metaConsequent.js +0 -108
  111. package/lib/metaLemmaMetatheorem.js +0 -191
  112. package/lib/metaSupposition.js +0 -160
  113. package/lib/node/metastatement/bracketed.js +0 -16
  114. package/lib/step/metaproof.js +0 -106
  115. package/lib/substitution/metastatementForMetavariable.js +0 -173
  116. package/lib/verify/metaConsequent.js +0 -50
  117. package/lib/verify/metaDerivation.js +0 -31
  118. package/lib/verify/metaSubDerivation.js +0 -25
  119. package/lib/verify/metaSubproof.js +0 -34
  120. package/lib/verify/metaSupposition.js +0 -61
  121. package/lib/verify/metaSuppositions.js +0 -28
  122. package/lib/verify/metaproof.js +0 -31
  123. package/lib/verify/metaproofStep.js +0 -98
  124. package/lib/verify/metastatement/qualified.js +0 -95
  125. package/lib/verify/metastatement/unqualified.js +0 -37
  126. package/lib/verify/metastatementAsContainedAssertion.js +0 -109
  127. package/lib/verify/metastatementAsDefinedAssertion.js +0 -132
  128. package/lib/verify/metavariableAgainstMetastatement.js +0 -44
  129. package/lib/verify/statementAsContainedAssertion.js +0 -109
  130. package/lib/verify/statementAsDefinedAssertion.js +0 -132
  131. package/src/metaConsequent.js +0 -83
  132. package/src/metaLemmaMetatheorem.js +0 -188
  133. package/src/metaSupposition.js +0 -127
  134. package/src/node/metastatement/bracketed.js +0 -9
  135. package/src/step/metaproof.js +0 -73
  136. package/src/substitution/metastatementForMetavariable.js +0 -90
  137. package/src/verify/metaConsequent.js +0 -61
  138. package/src/verify/metaDerivation.js +0 -23
  139. package/src/verify/metaSubDerivation.js +0 -22
  140. package/src/verify/metaSubproof.js +0 -32
  141. package/src/verify/metaSupposition.js +0 -78
  142. package/src/verify/metaSuppositions.js +0 -17
  143. package/src/verify/metaproof.js +0 -28
  144. package/src/verify/metaproofStep.js +0 -137
  145. package/src/verify/metastatement/qualified.js +0 -130
  146. package/src/verify/metastatement/unqualified.js +0 -34
  147. package/src/verify/metastatementAsContainedAssertion.js +0 -127
  148. package/src/verify/metastatementAsDefinedAssertion.js +0 -156
  149. package/src/verify/metavariableAgainstMetastatement.js +0 -42
  150. /package/src/{step/proof.js → proofStep.js} +0 -0
package/src/premise.js CHANGED
@@ -7,27 +7,18 @@ import intrinsicLevelAgainstMetaLevelNodesVerifier from "./verifier/nodes/intrin
7
7
  import { match } from "./utilities/array";
8
8
  import { nodeAsString } from "./utilities/string";
9
9
  import { nodeQuery, nodesQuery } from "./utilities/query";
10
- import { statementNodeFromStatementString, metastatementNodeFromMetastatementString } from "./utilities/node";
10
+ import { statementNodeFromStatementString } from "./utilities/node";
11
11
 
12
- const subproofAssertionNodeQuery = nodeQuery("/metastatement/subproofAssertion!"),
13
- subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement!/statement!"),
14
- subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!"),
15
- subproofAssertionMetastatementNodesQuery = nodesQuery("/subproofAssertion/metastatement"),
16
- ruleSubproofPremiseMetastatementNodesQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
17
- metaSubproofMetaSuppositionMetastatementNodesQuery = nodesQuery("/metaSubproof/metaSupposition/unqualifiedMetastatement!/metastatement!"),
18
- ruleSubproofLastRuleProofStepMetastatementNodeQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/lastRuleProofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!"),
19
- metaSubproofLastMetaproofStepMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/lastMetaproofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!");
12
+ const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
13
+ subproofPremiseStatementNodesQuery = nodesQuery("/subproof/premise/unqualifiedStatement!/statement!"),
14
+ subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
15
+ subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
20
16
 
21
17
  export default class Premise {
22
- constructor(metastatementNode, statementNode) {
23
- this.metastatementNode = metastatementNode;
18
+ constructor(statementNode) {
24
19
  this.statementnode = statementNode;
25
20
  }
26
21
 
27
- getMetastatementNode() {
28
- return this.metastatementNode;
29
- }
30
-
31
22
  getStatementNode() {
32
23
  return this.statementnode;
33
24
  }
@@ -35,9 +26,9 @@ export default class Premise {
35
26
  matchStatementNode(statementNode, substitutions, fileContext, localContext) {
36
27
  let matchesStatementNode = false;
37
28
 
38
- if (this.metastatementNode !== null) {
29
+ if (this.statementNode !== null) {
39
30
  const fileContextA = fileContext, ///
40
- nonTerminalNodeA = this.metastatementNode, ///
31
+ nonTerminalNodeA = this.statementNode, ///
41
32
  nonTerminalNodeB = statementNode, ///
42
33
  localContextA = LocalContext.fromFileContext(fileContextA),
43
34
  localContextB = localContext, ///
@@ -56,98 +47,24 @@ export default class Premise {
56
47
  matchSubproofNode(subproofNode, substitutions, fileContext, localContext) {
57
48
  let matchesSubproofNode = false;
58
49
 
59
- if (this.metastatementNode !== null) {
60
- const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
50
+ if (this.statementNode !== null) {
51
+ const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
61
52
 
62
53
  if (subproofAssertionNode !== null) {
63
- const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
54
+ const subproofPremiseStatementNodes = subproofPremiseStatementNodesQuery(subproofNode),
64
55
  subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
65
56
  subproofStatementNodes = [
66
- ...subproofSuppositionStatementNodes,
57
+ ...subproofPremiseStatementNodes,
67
58
  subproofLastProofStepStatementNode
68
59
  ],
69
- subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
60
+ subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode);
70
61
 
71
- matchesSubproofNode = match(subproofAssertionMetastatementNodes, subproofStatementNodes, (subproofAssertionMetastatementNode, subproofStatementNode) => {
62
+ matchesSubproofNode = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
72
63
  const fileContextA = fileContext, ///
73
- nonTerminalNodeA = subproofAssertionMetastatementNode, ///
64
+ nonTerminalNodeA = subproofAssertionStatementNode, ///
74
65
  nonTerminalNodeB = subproofStatementNode, ///
75
66
  localContextA = LocalContext.fromFileContext(fileContextA),
76
67
  localContextB = localContext, ///
77
- nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
78
- const verifiedAhead = true;
79
-
80
- return verifiedAhead;
81
- });
82
-
83
- if (nonTerminalNodeVerified) {
84
- return true;
85
- }
86
- });
87
- }
88
- }
89
-
90
- return matchesSubproofNode;
91
- }
92
-
93
- matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localContext) {
94
- let matchesRuleSubproofNode = false;
95
-
96
- if (this.metastatementNode !== null) {
97
- const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
98
-
99
- if (subproofAssertionNode !== null) {
100
- const ruleSubproofPremiseMetastatementNodes = ruleSubproofPremiseMetastatementNodesQuery(ruleSubproofNode),
101
- ruleSubproofLastRuleProofStepMetastatementNode = ruleSubproofLastRuleProofStepMetastatementNodeQuery(ruleSubproofNode),
102
- ruleSubproofMetastatementNodes = [
103
- ...ruleSubproofPremiseMetastatementNodes,
104
- ruleSubproofLastRuleProofStepMetastatementNode
105
- ],
106
- subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
107
-
108
- matchesRuleSubproofNode = match(subproofAssertionMetastatementNodes, ruleSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
109
- const fileContextA = fileContext, ///
110
- nonTerminalNodeA = subproofAssertionMetastatementNode, ///
111
- nonTerminalNodeB = ruleSubproofMetastatementNode, ///
112
- localContextA = LocalContext.fromFileContext(fileContextA),
113
- localContextB = localContext, ///
114
- nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
115
- const verifiedAhead = true;
116
-
117
- return verifiedAhead;
118
- });
119
-
120
- if (nonTerminalNodeVerified) {
121
- return true;
122
- }
123
- });
124
- }
125
- }
126
-
127
- return matchesRuleSubproofNode;
128
- }
129
-
130
- matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localContext) {
131
- let matchesMetaSubproofNode = false;
132
-
133
- if (this.metastatementNode !== null) {
134
- const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
135
-
136
- if (subproofAssertionNode !== null) {
137
- const metaSubproofMetaSuppositionMetastatementNodes = metaSubproofMetaSuppositionMetastatementNodesQuery(metaSubproofNode),
138
- metaSubproofLastMetaproofStepMetastatementNode = metaSubproofLastMetaproofStepMetastatementNodeQuery(metaSubproofNode),
139
- metaSubproofMetastatementNodes = [
140
- ...metaSubproofMetaSuppositionMetastatementNodes,
141
- metaSubproofLastMetaproofStepMetastatementNode
142
- ],
143
- subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
144
-
145
- matchesMetaSubproofNode = match(subproofAssertionMetastatementNodes, metaSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
146
- const fileContextA = fileContext, ///
147
- nonTerminalNodeA = subproofAssertionMetastatementNode, ///
148
- nonTerminalNodeB = ruleSubproofMetastatementNode, ///
149
- localContextA = LocalContext.fromFileContext(fileContextA),
150
- localContextB = localContext, ///
151
68
  nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
152
69
  const verifiedAhead = true;
153
70
 
@@ -161,37 +78,13 @@ export default class Premise {
161
78
  }
162
79
  }
163
80
 
164
- return matchesMetaSubproofNode;
165
- }
166
-
167
- matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext) {
168
- let matchesMetastatementNode = false;
169
-
170
- if (this.metastatementNode !== null) {
171
- const fileContextA = fileContext, ///
172
- nonTerminalNodeA = this.metastatementNode, ///
173
- nonTerminalNodeB = metastatementNode, ///
174
- localContextA = LocalContext.fromFileContext(fileContextA),
175
- localContextB = localContext, ///
176
- nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
177
- const verifiedAhead = true;
178
-
179
- return verifiedAhead;
180
- });
181
-
182
- matchesMetastatementNode = nonTerminalNodeVerified; ///
183
- }
184
-
185
- return matchesMetastatementNode;
81
+ return matchesSubproofNode;
186
82
  }
187
83
 
188
84
  toJSON(tokens) {
189
- const metastatementString = nodeAsString(this.metastatementNode, tokens),
190
- statementString = nodeAsString(this.statementnode, tokens),
191
- metastatement = metastatementString, ///
85
+ const statementString = nodeAsString(this.statementnode, tokens),
192
86
  statement = statementString, ///
193
87
  json = {
194
- metastatement,
195
88
  statement
196
89
  };
197
90
 
@@ -199,28 +92,18 @@ export default class Premise {
199
92
  }
200
93
 
201
94
  static fromStatementNode(statementNode) {
202
- const metastatementNode = null,
203
- premise = new Premise(metastatementNode, statementNode);
204
-
205
- return premise;
206
- }
207
-
208
- static fromMetastatementNode(metastatementNode) {
209
- const statementNode = null,
210
- premise = new Premise(metastatementNode, statementNode);
95
+ const premise = new Premise(statementNode);
211
96
 
212
97
  return premise;
213
98
  }
214
99
 
215
100
  static fromJSONAndFileContext(json, fileContext) {
216
- const { metastatement, statement } = json,
217
- metastatementString = metastatement, ///
101
+ const { statement } = json,
218
102
  statementString = statement, ///
219
103
  lexer = fileContext.getLexer(),
220
104
  parser = fileContext.getParser(),
221
- metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
222
105
  statementNode = statementNodeFromStatementString(statementString, lexer, parser),
223
- premise = new Premise(metastatementNode, statementNode);
106
+ premise = new Premise(statementNode, statementNode);
224
107
 
225
108
  return premise;
226
109
  }
package/src/rule.js CHANGED
@@ -46,22 +46,6 @@ export default class Rule {
46
46
  return matchesStatement;
47
47
  }
48
48
 
49
- matchMetastatement(metastatementNode, localContext) {
50
- let matchesMetastatement = false;
51
-
52
- const metaproofSteps = localContext.getMetaproofSteps(),
53
- substitutions = [],
54
- premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, localContext);
55
-
56
- if (premisesMatch) {
57
- const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localContext);
58
-
59
- matchesMetastatement = conclusionMatches; ///
60
- }
61
-
62
- return matchesMetastatement;
63
- }
64
-
65
49
  matchMetavariableNode(metavariableNode) {
66
50
  const matchesMetavariableNode = this.labels.some((label) => {
67
51
  const labelMatchesMetavariableNode = label.matchMetavariableNode(metavariableNode);
@@ -186,54 +170,3 @@ function matchConclusion(conclusion, statementNode, substitutions, fileContext,
186
170
 
187
171
  return conclusionMatches;
188
172
  }
189
-
190
- function metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localContext) {
191
- let premiseMatches = false;
192
-
193
- const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
194
- metaSubproofNode = metaproofStep.getMetaSubproofNode(),
195
- metastatementNode = metaproofStep.getMetastatementNode()
196
-
197
- if (ruleSubproofNode !== null) {
198
- const premiseMatchesRuleSubproofNode = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localContext);
199
-
200
- premiseMatches = premiseMatchesRuleSubproofNode; ///
201
- }
202
-
203
- if (metaSubproofNode !== null) {
204
- const premiseMatchesMetaSubproofNode = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localContext);
205
-
206
- premiseMatches = premiseMatchesMetaSubproofNode; ///
207
- }
208
-
209
- if (metastatementNode !== null) {
210
- const premiseMatchesMetastatementNode = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext);
211
-
212
- premiseMatches = premiseMatchesMetastatementNode; ///
213
- }
214
-
215
- return premiseMatches;
216
- }
217
-
218
- function metaMatchPremises(premises, metaproofSteps, substitutions, fileContext, localContext) {
219
- premises = reverse(premises); ///
220
-
221
- metaproofSteps = reverse(metaproofSteps); ///
222
-
223
- const premisesMatch = correlate(premises, metaproofSteps, (premise, metaproofStep) => {
224
- const premiseMatches = metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localContext);
225
-
226
- if (premiseMatches) {
227
- return true;
228
- }
229
- });
230
-
231
- return premisesMatch;
232
- }
233
-
234
- function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, localContext) {
235
- const conclusionMatchesMetastatementNode = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext),
236
- conclusionMatches = conclusionMatchesMetastatementNode; ///
237
-
238
- return conclusionMatches;
239
- }
package/src/ruleNames.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  export const METAVARIABLE_RULE_NAME = "metavariable";
4
- export const META_ARGUMENT_RULE_NAME = "metaArgument";
5
4
  export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
6
5
  export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
7
6
  export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
8
- export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
@@ -5,6 +5,7 @@ import TermForVariableSubstitution from "./termForVariable";
5
5
  import verifyStatementAgainstStatement from "../verify/statementAtainstStatement";
6
6
 
7
7
  import { bracketedStatementChildNodeFromStatementNode } from "../utilities/match";
8
+ import { statementNodeFromStatementString, metavariableNodeFromMetavariableString } from "../utilities/node";
8
9
 
9
10
  export default class StatementForMetavariableSubstitution extends Substitution {
10
11
  constructor(metavariableNode, statementNode, substitution) {
@@ -55,6 +56,19 @@ export default class StatementForMetavariableSubstitution extends Substitution {
55
56
  return matchesMetavariableNode;
56
57
  }
57
58
 
59
+ static fromJSONAndFileContext(json, fileContext) {
60
+ const { metavariable, statement } = json,
61
+ metavariableString = metavariable, ///
62
+ statementString = statement, ///
63
+ lexer = fileContext.getLexer(),
64
+ parser = fileContext.getParser(),
65
+ statementNode = statementNodeFromStatementString(statementString, lexer, parser),
66
+ metavariableNode = metavariableNodeFromMetavariableString(metavariableString, lexer, parser),
67
+ statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode);
68
+
69
+ return statementForMetavariableSubstitution;
70
+ }
71
+
58
72
  static fromMetavariableNodeAndStatementNode(metavariableNode, statementNode) {
59
73
  let statementForMetavariableSubstitution;
60
74
 
@@ -24,10 +24,4 @@ export default class Substitution {
24
24
 
25
25
  return matchesMetavariableNode;
26
26
  }
27
-
28
- matchMetastatementNode(metastatementNode) {
29
- const matchesMetastatementNode = false;
30
-
31
- return matchesMetastatementNode;
32
- }
33
27
  }
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ import LocalContext from "./context/local";
4
+ import metaLevelNodesVerifier from "./verifier/nodes/metaLevel";
3
5
  import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
4
6
 
7
+ import { match } from "./utilities/array";
5
8
  import { nodeAsString } from "./utilities/string";
6
9
  import { statementNodeFromStatementString } from "./utilities/node";
10
+ import {nodeQuery, nodesQuery} from "./utilities/query";
11
+
12
+ const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
13
+ subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
14
+ subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
15
+ subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
7
16
 
8
17
  export default class Supposition {
9
18
  constructor(statementNode) {
@@ -29,6 +38,43 @@ export default class Supposition {
29
38
  return matchesStatementNode;
30
39
  }
31
40
 
41
+ matchSubproofNode(subproofNode, substitutions, fileContext, localContext) {
42
+ let matchesSubproofNode = false;
43
+
44
+ if (this.statementNode !== null) {
45
+ const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
46
+
47
+ if (subproofAssertionNode !== null) {
48
+ const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
49
+ subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
50
+ subproofStatementNodes = [
51
+ ...subproofSuppositionStatementNodes,
52
+ subproofLastProofStepStatementNode
53
+ ],
54
+ subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode);
55
+
56
+ matchesSubproofNode = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, ruleSubproofStatementNode) => {
57
+ const fileContextA = fileContext, ///
58
+ nonTerminalNodeA = subproofAssertionStatementNode, ///
59
+ nonTerminalNodeB = ruleSubproofStatementNode, ///
60
+ localContextA = LocalContext.fromFileContext(fileContextA), ///
61
+ localContextB = localContext, ///
62
+ nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
63
+ const verifiedAhead = true;
64
+
65
+ return verifiedAhead;
66
+ });
67
+
68
+ if (nonTerminalNodeVerified) {
69
+ return true;
70
+ }
71
+ });
72
+ }
73
+ }
74
+
75
+ return matchesSubproofNode;
76
+ }
77
+
32
78
  toJSON(tokens) {
33
79
  const statementString = nodeAsString(this.statementNode, tokens),
34
80
  statement = statementString, ///
package/src/theorem.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- import AxiomLemmaTheoremConjecture from "./axiomLemmaTheoremConjecture";
3
+ import TopLevelAssertion from "./topLevelAssertion";
4
4
 
5
- export default class Theorem extends AxiomLemmaTheoremConjecture {
6
- static fromJSONAndFileContext(json, fileContext) { return AxiomLemmaTheoremConjecture.fromJSONAndFileContext(Theorem, json, fileContext); }
5
+ export default class Theorem extends TopLevelAssertion {
6
+ static fromJSONAndFileContext(json, fileContext) { return TopLevelAssertion.fromJSONAndFileContext(Theorem, json, fileContext); }
7
7
 
8
- static fromLabelsSuppositionsConsequentAndLocalContext(labels, suppositions, consequent, localContext) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsConsequentAndLocalContext(Theorem, labels, suppositions, consequent, localContext); }
8
+ static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return TopLevelAssertion.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Theorem, labels, suppositions, consequent, substitutions, fileContext); }
9
9
  }
@@ -3,16 +3,17 @@
3
3
  import Label from "./label";
4
4
  import Consequent from "./consequent";
5
5
  import Supposition from "./supposition";
6
- import LocalContext from "./context/local";
6
+ import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
7
7
 
8
8
  import { reverse, correlate } from "./utilities/array";
9
9
 
10
- export default class AxiomLemmaTheoremConjecture {
11
- constructor(labels, suppositions, consequent, localContext) {
10
+ export default class TopLevelAssertion {
11
+ constructor(labels, suppositions, consequent, substitutions, fileContext) {
12
12
  this.labels = labels;
13
13
  this.suppositions = suppositions;
14
14
  this.consequent = consequent;
15
- this.localContext = localContext;
15
+ this.substitutions = substitutions;
16
+ this.fileContext = fileContext;
16
17
  }
17
18
 
18
19
  getLabels() {
@@ -27,8 +28,12 @@ export default class AxiomLemmaTheoremConjecture {
27
28
  return this.consequent;
28
29
  }
29
30
 
30
- getLocalContext() {
31
- return this.localContext;
31
+ getSubstitutions() {
32
+ return this.substitutions;
33
+ }
34
+
35
+ getFileContext() {
36
+ return this.fileContext;
32
37
  }
33
38
 
34
39
  matchStatement(statementNode, localContext) {
@@ -36,10 +41,10 @@ export default class AxiomLemmaTheoremConjecture {
36
41
 
37
42
  const proofSteps = localContext.getProofSteps(),
38
43
  substitutions = [],
39
- suppositionsMatch = matchSuppositions(this.suppositions, proofSteps, substitutions, this.localContext, localContext);
44
+ suppositionsMatch = matchSuppositions(this.suppositions, proofSteps, substitutions, this.fileContext, localContext);
40
45
 
41
46
  if (suppositionsMatch) {
42
- const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.localContext, localContext);
47
+ const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.fileContext, localContext);
43
48
 
44
49
  statementNatches = consequentMatches; ///
45
50
  }
@@ -71,16 +76,20 @@ export default class AxiomLemmaTheoremConjecture {
71
76
  return suppositionJSON;
72
77
  }),
73
78
  consequentJSON = this.consequent.toJSON(tokens),
74
- localContextJSON = this.localContext.toJSON(tokens),
79
+ substitutionsJSON = this.substitutions.map((substitution) => {
80
+ const substitutionJSON = substitution.toJSON();
81
+
82
+ return substitutionJSON;
83
+ }),
75
84
  labels = labelsJSON, ///
76
85
  suppositions = suppositionsJSON, ///
77
86
  consequent = consequentJSON, ///
78
- localContext = localContextJSON, ///
87
+ substitutions = substitutionsJSON, ///
79
88
  json = {
80
89
  labels,
81
90
  suppositions,
82
91
  consequent,
83
- localContext
92
+ substitutions
84
93
  };
85
94
 
86
95
  return json;
@@ -98,7 +107,7 @@ export default class AxiomLemmaTheoremConjecture {
98
107
  return label;
99
108
  });
100
109
 
101
- let { suppositions, consequent, localContext } = json;
110
+ let { suppositions, consequent, substitutions } = json;
102
111
 
103
112
  const suppositionsJSON = suppositions; ///
104
113
 
@@ -115,25 +124,29 @@ export default class AxiomLemmaTheoremConjecture {
115
124
 
116
125
  consequent = Consequent.fromJSONAndFileContext(json, fileContext);
117
126
 
118
- const localContextJSON = localContext; ///
127
+ const substitutionsJSON = substitutions; ///
119
128
 
120
- json = localContextJSON; ///
129
+ substitutions = substitutionsJSON.map((substitutionJSON) => {
130
+ const json = substitutionJSON, ///
131
+ statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromJSONAndFileContext(json, fileContext),
132
+ substitution = statementForMetavariableSubstitution; ///
121
133
 
122
- localContext = LocalContext.fromJSONAndFileContext(json, fileContext);
134
+ return substitution;
135
+ });
123
136
 
124
- return new Class(labels, suppositions, consequent, localContext); ///
137
+ return new Class(labels, suppositions, consequent, substitutions, fileContext); ///
125
138
  }
126
139
 
127
- static fromLabelsSuppositionsConsequentAndLocalContext(Class, labels, suppositions, consequent, localContext) { return new Class(labels, suppositions, consequent, localContext); }
140
+ static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Class, labels, suppositions, consequent, substitutions, fileContext) { return new Class(labels, suppositions, consequent, substitutions, fileContext); }
128
141
  }
129
142
 
130
- function matchSuppositions(suppositions, proofSteps, substitutions, localContext, statementLocalContext) {
143
+ function matchSuppositions(suppositions, proofSteps, substitutions, fileContext, localContext) {
131
144
  suppositions = reverse(suppositions); ///
132
145
 
133
146
  proofSteps = reverse(proofSteps); ///
134
147
 
135
148
  const suppositionsMatch = correlate(suppositions, proofSteps, (supposition, proofStep) => {
136
- const suppositionMatches = matchSupposition(supposition, proofStep, substitutions, localContext, statementLocalContext);
149
+ const suppositionMatches = matchSupposition(supposition, proofStep, substitutions, fileContext, localContext);
137
150
 
138
151
  if (suppositionMatches) {
139
152
  return true;
@@ -143,13 +156,13 @@ function matchSuppositions(suppositions, proofSteps, substitutions, localContext
143
156
  return suppositionsMatch;
144
157
  }
145
158
 
146
- function matchSupposition(supposition, proofStep, substitutions, localContext, statementLocalContext) {
159
+ function matchSupposition(supposition, proofStep, substitutions, fileContext, localContext) {
147
160
  let suppositionMatches = false;
148
161
 
149
162
  const statementNode = proofStep.getStatementNode();
150
163
 
151
164
  if (statementNode !== null) {
152
- const suppositionMatchesStatementNode = supposition.matchStatementNode(statementNode, substitutions, localContext, statementLocalContext);
165
+ const suppositionMatchesStatementNode = supposition.matchStatementNode(statementNode, substitutions, fileContext, localContext);
153
166
 
154
167
  suppositionMatches = suppositionMatchesStatementNode; ///
155
168
  }
@@ -157,8 +170,8 @@ function matchSupposition(supposition, proofStep, substitutions, localContext, s
157
170
  return suppositionMatches;
158
171
  }
159
172
 
160
- function matchConsequent(consequent, statementNode, substitutions, localContext, statementLocalContext) {
161
- const consequentMatchesStatementNode = consequent.matchStatementNode(statementNode, substitutions, localContext, statementLocalContext),
173
+ function matchConsequent(consequent, statementNode, substitutions, fileContext, localContext) {
174
+ const consequentMatchesStatementNode = consequent.matchStatementNode(statementNode, substitutions, fileContext, localContext),
162
175
  consequentMatches = consequentMatchesStatementNode; ///
163
176
 
164
177
  return consequentMatches;
@@ -5,11 +5,10 @@ import { CustomGrammar, CombinedCustomGrammar } from "occam-custom-grammars";
5
5
  export function customGrammarFromNameAndEntries(name, entries) {
6
6
  const termBNF = entries.getTermBNF(),
7
7
  statementBNF = entries.getStatementBNF(),
8
- metastatementBNF = entries.getMetastatementBNF(),
9
8
  typePattern = entries.getTypePattern(),
10
9
  symbolPattern = entries.getSymbolPattern(),
11
10
  operatorPattern = entries.getOperatorPattern(),
12
- customGrammar = CustomGrammar.fromNameTermBNFStatementBNFMetastatementBNFTypePatternSymbolPatternAndOperatorPattern(name, termBNF, statementBNF, metastatementBNF, typePattern, symbolPattern, operatorPattern);
11
+ customGrammar = CustomGrammar.fromNameTermBNFStatementBNFTypePatternSymbolPatternAndOperatorPattern(name, termBNF, statementBNF, typePattern, symbolPattern, operatorPattern);
13
12
 
14
13
  return customGrammar;
15
14
  }