occam-verify-cli 0.0.1061 → 0.0.1065

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 (78) hide show
  1. package/bin/action/verify.js +2 -0
  2. package/lib/assertion/contained.js +184 -0
  3. package/lib/assertion/defined.js +171 -0
  4. package/lib/assertion/subproof.js +5 -5
  5. package/lib/assertion/type.js +13 -6
  6. package/lib/conclusion.js +5 -8
  7. package/lib/consequent.js +5 -8
  8. package/lib/context/release.js +3 -2
  9. package/lib/declaration.js +6 -50
  10. package/lib/equality.js +6 -7
  11. package/lib/equivalence.js +3 -2
  12. package/lib/frame.js +160 -64
  13. package/lib/metavariable.js +49 -39
  14. package/lib/mixins/statement/verify.js +24 -32
  15. package/lib/premise.js +5 -8
  16. package/lib/proofStep.js +2 -2
  17. package/lib/statement/unqualified.js +14 -1
  18. package/lib/statement.js +77 -23
  19. package/lib/substitution/statement.js +17 -2
  20. package/lib/substitution/statementForMetavariable.js +22 -27
  21. package/lib/substitution/termForVariable.js +9 -9
  22. package/lib/supposition.js +5 -8
  23. package/lib/term.js +46 -3
  24. package/lib/unifier/intrinsicLevel.js +4 -4
  25. package/lib/unifier/metaLevel.js +9 -13
  26. package/lib/unifier/metavariable.js +4 -4
  27. package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +3 -3
  28. package/lib/unify/statementWithSttaemetnGivenEquivalences.js +5 -5
  29. package/lib/utilities/unify.js +4 -21
  30. package/lib/variable.js +19 -3
  31. package/lib/verifier/intrinsicLevel.js +4 -4
  32. package/lib/verifier/metaLevel.js +4 -4
  33. package/lib/verifier/substitution.js +161 -0
  34. package/lib/verifier/topLevel.js +4 -4
  35. package/package.json +1 -1
  36. package/src/assertion/contained.js +170 -0
  37. package/src/assertion/defined.js +161 -0
  38. package/src/assertion/subproof.js +5 -4
  39. package/src/assertion/type.js +18 -7
  40. package/src/conclusion.js +5 -18
  41. package/src/consequent.js +5 -18
  42. package/src/context/release.js +3 -1
  43. package/src/declaration.js +49 -49
  44. package/src/equality.js +7 -8
  45. package/src/equivalence.js +3 -1
  46. package/src/frame.js +204 -59
  47. package/src/metavariable.js +82 -45
  48. package/src/mixins/statement/verify.js +30 -42
  49. package/src/premise.js +5 -18
  50. package/src/proofStep.js +1 -1
  51. package/src/statement/unqualified.js +17 -0
  52. package/src/statement.js +116 -32
  53. package/src/substitution/statement.js +22 -2
  54. package/src/substitution/statementForMetavariable.js +27 -34
  55. package/src/substitution/termForVariable.js +15 -12
  56. package/src/supposition.js +5 -18
  57. package/src/term.js +61 -3
  58. package/src/unifier/intrinsicLevel.js +3 -3
  59. package/src/unifier/metaLevel.js +16 -21
  60. package/src/unifier/metavariable.js +3 -3
  61. package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +2 -2
  62. package/src/unify/statementWithSttaemetnGivenEquivalences.js +4 -4
  63. package/src/utilities/unify.js +0 -14
  64. package/src/variable.js +27 -3
  65. package/src/verifier/intrinsicLevel.js +3 -3
  66. package/src/verifier/metaLevel.js +3 -3
  67. package/src/verifier/substitution.js +75 -0
  68. package/src/verifier/topLevel.js +3 -3
  69. package/lib/unify/frameWithMetaType.js +0 -24
  70. package/lib/verify/assertion/contained.js +0 -107
  71. package/lib/verify/assertion/defined.js +0 -98
  72. package/lib/verify/assertion/subproof.js +0 -16
  73. package/lib/verify/frameGivenMetaType.js +0 -37
  74. package/src/unify/frameWithMetaType.js +0 -14
  75. package/src/verify/assertion/contained.js +0 -134
  76. package/src/verify/assertion/defined.js +0 -120
  77. package/src/verify/assertion/subproof.js +0 -9
  78. package/src/verify/frameGivenMetaType.js +0 -31
package/src/frame.js CHANGED
@@ -1,107 +1,252 @@
1
1
  "use strict";
2
2
 
3
- import { arrayUtilities } from "necessary";
3
+ import shim from "./shim";
4
+ import Declaration from "./declaration";
5
+ import Metavariable from "./metavariable";
4
6
 
5
- import { metavariableNameFromMetavariableNode } from "./utilities/name";
7
+ import { FRAME_META_TYPE_NAME } from "./metaTypeNames";
8
+ import { nodeQuery, nodesQuery } from "./utilities/query";
6
9
 
7
- const { first } = arrayUtilities;
10
+ const declarationNodesQuery = nodesQuery("/frame/declaration"),
11
+ metavariableNodesQuery = nodesQuery("/frame/metavariable"),
12
+ frameMetavariableNodeQuery = nodeQuery("/*/frame/metavariable!");
8
13
 
9
- export default class Frame {
10
- constructor(declarations, metavariableNodes) {
14
+ class Frame {
15
+ constructor(string, declarations, metavariables) {
16
+ this.string = string;
11
17
  this.declarations = declarations;
12
- this.metavariableNodes = metavariableNodes;
18
+ this.metavariables = metavariables;
19
+ }
20
+
21
+ getString() {
22
+ return this.string;
13
23
  }
14
24
 
15
25
  getDeclarations() {
16
26
  return this.declarations;
17
27
  }
18
28
 
19
- getMetavariableNodes() {
20
- return this.metavariableNodes;
29
+ getMetavariables() {
30
+ return this.metavariables;
21
31
  }
22
32
 
23
- getMetavariableNode() {
24
- let metavariableNode = null;
33
+ getMetavariable() {
34
+ let metavariable;
25
35
 
26
- const declarationsLength = this.declarations.length;
36
+ const metavariablesLength = this.metavariables.length;
27
37
 
28
- if (declarationsLength === 0) {
29
- const metavariableNodesLength = this.metavariableNodes.length;
38
+ if (metavariablesLength === 1) {
39
+ const firstMetavariable = first(this.metavariables);
30
40
 
31
- if (metavariableNodesLength === 1) {
32
- const firstMetavariableNode = first(this.metavariableNodes);
33
-
34
- metavariableNode = firstMetavariableNode; ///
35
- }
41
+ metavariable = firstMetavariable; ///
36
42
  }
37
43
 
38
- return metavariableNode;
44
+ return metavariable;
39
45
  }
40
46
 
41
- matchMetavariableName(metavariableName) {
42
- let metavariableNameMatches = false;
43
-
44
- const metavariableNode = this.getMetavariableNode();
47
+ // getMetavariableNode() {
48
+ // let metavariableNode = null;
49
+ //
50
+ // const declarationsLength = this.declarations.length;
51
+ //
52
+ // if (declarationsLength === 0) {
53
+ // const metavariableNodesLength = this.metavariableNodes.length;
54
+ //
55
+ // if (metavariableNodesLength === 1) {
56
+ // const firstMetavariableNode = first(this.metavariableNodes);
57
+ //
58
+ // metavariableNode = firstMetavariableNode; ///
59
+ // }
60
+ // }
61
+ //
62
+ // return metavariableNode;
63
+ // }
64
+ //
65
+ // matchMetavariableName(metavariableName) {
66
+ // let metavariableNameMatches = false;
67
+ //
68
+ // const metavariableNode = this.getMetavariableNode();
69
+ //
70
+ // if (metavariableNode !== null) {
71
+ // const name = metavariableName; ///
72
+ //
73
+ // metavariableName = metavariableNameFromMetavariableNode(metavariableNode); ///
74
+ //
75
+ // const nameMatchesMetavariableName = (name === metavariableName);
76
+ //
77
+ // metavariableNameMatches = nameMatchesMetavariableName; ///
78
+ // }
79
+ //
80
+ // return metavariableNameMatches;
81
+ // }
82
+ //
83
+ // unifySubstitution(substitution) {
84
+ // const substitutionUnified = this.declarations.some((declaration) => {
85
+ // const substitutionUnifiedWithDeclaration = declaration.unifySubstitution(substitution);
86
+ //
87
+ // if (substitutionUnifiedWithDeclaration) {
88
+ // return true;
89
+ // }
90
+ // });
91
+ //
92
+ // return substitutionUnified;
93
+ // }
94
+ //
95
+ // unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem) {
96
+ // const substitutions = metaLemmaMetatheorem.getSubstitutions(),
97
+ // substitutionsUnified = substitutions.everySubstitution((substitution) => {
98
+ // const substitutionUnified = this.unifySubstitution(substitution);
99
+ //
100
+ // if (substitutionUnified) {
101
+ // return true;
102
+ // }
103
+ // }),
104
+ // metaLemmaOrMetaTheoremUnified = substitutionsUnified; ///
105
+ //
106
+ // return metaLemmaOrMetaTheoremUnified;
107
+ // }
108
+
109
+ verify(localContext) {
110
+ let verified;
111
+
112
+ const frameString = this.string; ///
113
+
114
+ localContext.trace(`Verifying the '${frameString}' frame...`);
115
+
116
+ const declarationsVerified = this.declarations.every((declaration) => {
117
+ const declarationVerified = declaration.verify(localContext);
118
+
119
+ return declarationVerified;
120
+ });
45
121
 
46
- if (metavariableNode !== null) {
47
- const name = metavariableName; ///
122
+ if (declarationsVerified) {
123
+ const metavariablesVerified = this.metavariables.every((metavariable) => {
124
+ const metavariableVerified = metavariable.verify(localContext);
48
125
 
49
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode); ///
126
+ return metavariableVerified;
127
+ });
50
128
 
51
- const nameMatchesMetavariableName = (name === metavariableName);
129
+ verified = metavariablesVerified; ///
130
+ }
52
131
 
53
- metavariableNameMatches = nameMatchesMetavariableName; ///
132
+ if (verified) {
133
+ localContext.debug(`...verified the '${frameString}' frame.`);
54
134
  }
55
135
 
56
- return metavariableNameMatches;
136
+ return verified;
57
137
  }
58
138
 
59
- unifySubstitution(substitution) {
60
- const substitutionUnified = this.declarations.some((declaration) => {
61
- const substitutionUnifiedWithDeclaration = declaration.unifySubstitution(substitution);
139
+ verifyGivenMetaType(metaType, localContext) {
140
+ let verifiedGivenMetaType = false;
62
141
 
63
- if (substitutionUnifiedWithDeclaration) {
64
- return true;
65
- }
66
- });
142
+ const frameString = this.string, ///
143
+ metaTypeString = metaType.getString();
67
144
 
68
- return substitutionUnified;
69
- }
145
+ localContext.trace(`Verifying the '${frameString}' frame given the '${metaTypeString}' meta-type...`);
70
146
 
71
- unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem) {
72
- const substitutions = metaLemmaMetatheorem.getSubstitutions(),
73
- substitutionsUnified = substitutions.everySubstitution((substitution) => {
74
- const substitutionUnified = this.unifySubstitution(substitution);
147
+ const metaTypeName = metaType.getName();
75
148
 
76
- if (substitutionUnified) {
77
- return true;
78
- }
79
- }),
80
- metaLemmaOrMetaTheoremUnified = substitutionsUnified; ///
149
+ if (metaTypeName === FRAME_META_TYPE_NAME) {
150
+ const verified = this.verify(localContext)
151
+
152
+ verifiedGivenMetaType = verified; ///
153
+ }
81
154
 
82
- return metaLemmaOrMetaTheoremUnified;
155
+ if (verifiedGivenMetaType) {
156
+ localContext.debug(`...verified the '${frameString}' frame given the '${metaTypeString}' meta-type.`);
157
+ }
158
+
159
+ return verifiedGivenMetaType;
83
160
  }
84
161
 
85
- static fromDeclarations(declarations) {
86
- const metavariableNodes = [],
87
- frame = new Frame(declarations, metavariableNodes);
162
+ static fromFrameNode(frameNode, localContext) {
163
+ const declarationNodes = declarationNodesQuery(frameNode),
164
+ metavariableNodes = metavariableNodesQuery(frameNode),
165
+ declarations = declarationNodes.map((declarationNode) => {
166
+ const declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
167
+
168
+ return declaration;
169
+ }),
170
+ metavariables = metavariableNodes.map((metavariableNode) => {
171
+ const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
172
+
173
+ return metavariable;
174
+ }),
175
+ node = frameNode, ///
176
+ string = localContext.nodeAsString(node),
177
+ frame = new Frame(string, declarations, metavariables);
88
178
 
89
179
  return frame;
90
180
  }
91
181
 
92
- static fromMetavariableNode(metavariableNode) {
93
- const declarations = [],
94
- metavariableNodes = [
95
- metavariableNode
96
- ],
97
- frame = new Frame(declarations, metavariableNodes);
182
+ static fromDefinedAssertionNode(definedAssertionNode, localContext) {
183
+ let frame = null;
184
+
185
+ const frameMetavariableNode = frameMetavariableNodeQuery(definedAssertionNode);
186
+
187
+ if (frameMetavariableNode !== null) {
188
+ const metavariableNode = frameMetavariableNode, ///
189
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
190
+ declarations = [],
191
+ metavariables = [
192
+ metavariable
193
+ ],
194
+ node = metavariableNode, ///
195
+ string = localContext.nodeAsString(node);
196
+
197
+ frame = new Frame(string, declarations, metavariables);
198
+ }
98
199
 
99
200
  return frame;
100
201
  }
101
202
 
102
- static fromDeclarationsAndMetavariableNodes(declarations, metavariableNodes) {
103
- const frame = new Frame(declarations, metavariableNodes);
203
+ static fromContainedAssertionNode(containedAssertionNode, localContext) {
204
+ let frame = null;
205
+
206
+ const frameMetavariableNode = frameMetavariableNodeQuery(containedAssertionNode);
207
+
208
+ if (frameMetavariableNode !== null) {
209
+ const metavariableNode = frameMetavariableNode, ///
210
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
211
+ declarations = [],
212
+ metavariables = [
213
+ metavariable
214
+ ],
215
+ node = metavariableNode, ///
216
+ string = localContext.nodeAsString(node);
217
+
218
+ frame = new Frame(string, declarations, metavariables);
219
+ }
104
220
 
105
221
  return frame;
106
222
  }
223
+
224
+ // static fromDeclarations(declarations) {
225
+ // const metavariableNodes = [],
226
+ // frame = new Frame(declarations, metavariableNodes);
227
+ //
228
+ // return frame;
229
+ // }
230
+ //
231
+ // static fromMetavariableNode(metavariableNode) {
232
+ // const declarations = [],
233
+ // metavariableNodes = [
234
+ // metavariableNode
235
+ // ],
236
+ // frame = new Frame(declarations, metavariableNodes);
237
+ //
238
+ // return frame;
239
+ // }
240
+ //
241
+ // static fromDeclarationsAndMetavariableNodes(declarations, metavariableNodes) {
242
+ // const frame = new Frame(declarations, metavariableNodes);
243
+ //
244
+ // return frame;
245
+ // }
107
246
  }
247
+
248
+ Object.assign(shim, {
249
+ Frame
250
+ });
251
+
252
+ export default Frame;
@@ -3,6 +3,7 @@
3
3
  import shim from "./shim";
4
4
  import Argument from "./argument";
5
5
  import LocalContext from "./context/local";
6
+ import metavariableUnifier from "./unifier/metavariable";
6
7
  import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
7
8
 
8
9
  import { nodeQuery } from "./utilities/query";
@@ -12,9 +13,9 @@ import { metavariableNodeFromMetavariableString } from "./utilities/node";
12
13
  const argumentNodeQuery = nodeQuery("/metavariable/argument"),
13
14
  metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
14
15
  metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
15
- statementMetavariableNodeQuery = nodeQuery("/statement/metavariable");
16
+ statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
16
17
 
17
- export default class Metavariable {
18
+ class Metavariable {
18
19
  constructor(fileContext, string, node, name, metaType) {
19
20
  this.fileContext = fileContext;
20
21
  this.string = string;
@@ -62,13 +63,25 @@ export default class Metavariable {
62
63
  }
63
64
 
64
65
  verify(localContext) {
65
- let verified = false;
66
+ let verified;
66
67
 
67
68
  const metavariableString = this.string; ///
68
69
 
69
70
  localContext.trace(`Verifying the '${metavariableString}' metavariable...`);
70
71
 
71
- debugger
72
+ const metavariableName = this.name,
73
+ metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
74
+
75
+ if (metavariable !== null) {
76
+ const metavariableA = metavariable, ///
77
+ metavariableB = this,
78
+ metavariableNodeA = metavariableA.getNode(), ///
79
+ metavariableNodeB = metavariableB.getNode(),
80
+ metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
81
+
82
+ verified = metavariableUnified; ///
83
+
84
+ }
72
85
 
73
86
  if (verified) {
74
87
  localContext.debug(`...verified the '${metavariableString}' metavariable.`);
@@ -116,7 +129,7 @@ export default class Metavariable {
116
129
  let statementUnified = false;
117
130
 
118
131
  const statementString = statement.getString(),
119
- metavariableString = this.string;
132
+ metavariableString = this.string; ///
120
133
 
121
134
  localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
122
135
 
@@ -159,42 +172,40 @@ export default class Metavariable {
159
172
 
160
173
  const statementString = statement.getString(),
161
174
  substitutionString = substitution.getString(),
162
- metavariableString = this.string;
163
-
164
- localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable givne the '${substitutionString}' substitution...`);
165
-
166
- // let metavariableUnifiedWithStatementGivenSubstitution = false;
167
- //
168
- // const metavariableNode = metavariable.getNode(),
169
- // substitutionNode = substitution.getNode(),
170
- // complexSubstitution = substitutions.findComplexSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
171
- //
172
- // if (complexSubstitution !== null) {
173
- // const statementNode = statement.getNode(),
174
- // statementNodeMatches = complexSubstitution.matchStatementNode(statementNode);
175
- //
176
- // if (statementNodeMatches) {
177
- // metavariableUnifiedWithStatementGivenSubstitution = true;
178
- // }
179
- // } else {
180
- // const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNode),
181
- // metavariableA = localContextA.findMetavariableByMetavariableName(metavariableNameA),
182
- // metavariableB = metavariableFromStatementNode(statement, localContextB);
183
- //
184
- // if (metavariableA === metavariableB) {
185
- // metavariableUnifiedWithStatementGivenSubstitution = false; ///
186
- // } else {
187
- // const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContextA, localContextB),
188
- // substitution = statementForMetavariableSubstitution; ///
189
- //
190
- // substitutions.addSubstitution(substitution, localContextA, localContextB);
191
- //
192
- // metavariableUnifiedWithStatementGivenSubstitution = true;
193
- // }
194
- // }
175
+ metavariableString = this.string; ///
176
+
177
+ localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the '${substitutionString}' substitution...`);
178
+
179
+ const statementNode = statement.getNode(),
180
+ metavariableNode = this.node, ///
181
+ substitutionNode = substitution.getNode(),
182
+ complexSubstitution = substitutions.findComplexSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
183
+
184
+ if (complexSubstitution !== null) {
185
+ const statementNodeMatches = complexSubstitution.matchStatementNode(statementNode);
186
+
187
+ if (statementNodeMatches) {
188
+ statementUnifiedGivenSubstitution = true;
189
+ }
190
+ } else {
191
+ const metavariable = metavariableFromStatementNode(statementNode, localContext);
192
+
193
+ if (this === metavariable) { ///
194
+ statementUnifiedGivenSubstitution = false; ///
195
+ } else {
196
+ const metavariable = this, ///
197
+ statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
198
+
199
+ substitution = statementForMetavariableSubstitution; ///
200
+
201
+ substitutions.addSubstitution(substitution, localContext);
202
+
203
+ statementUnifiedGivenSubstitution = true;
204
+ }
205
+ }
195
206
 
196
207
  if (statementUnifiedGivenSubstitution) {
197
- localContext.trace(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable givne the '${substitutionString}' substitution.`);
208
+ localContext.trace(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the '${substitutionString}' substitution.`);
198
209
  }
199
210
 
200
211
  return statementUnifiedGivenSubstitution;
@@ -230,12 +241,17 @@ export default class Metavariable {
230
241
  }
231
242
 
232
243
  static fromMetavariableNode(metavariableNode, fileContext) {
233
- const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
234
- node = metavariableNode, ///
235
- name = metavariableName, ///
236
- string = fileContext.nodeAsString(node),
237
- metaType = null,
238
- metavariable = new Metavariable(fileContext, string, node, name, metaType);
244
+ let metavariable = null;
245
+
246
+ if (metavariableNode !== null) {
247
+ const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
248
+ node = metavariableNode, ///
249
+ name = metavariableName, ///
250
+ string = fileContext.nodeAsString(node),
251
+ metaType = null;
252
+
253
+ metavariable = new Metavariable(fileContext, string, node, name, metaType);
254
+ }
239
255
 
240
256
  return metavariable;
241
257
  }
@@ -257,6 +273,12 @@ export default class Metavariable {
257
273
  }
258
274
  }
259
275
 
276
+ Object.assign(shim, {
277
+ Metavariable
278
+ });
279
+
280
+ export default Metavariable;
281
+
260
282
  function metaTypeFromJSON(json, fileContext) {
261
283
  let { metaType } = json;
262
284
 
@@ -270,6 +292,21 @@ function metaTypeFromJSON(json, fileContext) {
270
292
  return metaType;
271
293
  }
272
294
 
295
+ function metavariableFromStatementNode(statementNode, localContext) {
296
+ let metavariable = null;
297
+
298
+ const statementMetavariableNode = statementMetavariableNodeQuery(statementNode)
299
+
300
+ if (statementMetavariableNode !== null) {
301
+ const metavariableNode = statementMetavariableNode, ///
302
+ metavariableName = metavariableNameFromMetavariableNode(metavariableNode);
303
+
304
+ metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
305
+ }
306
+
307
+ return metavariable;
308
+ }
309
+
273
310
  function statementMetavariableFromStatementNode(statementNode, localContext) {
274
311
  let statementMetavariable = null;
275
312
 
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  import Equality from "../../equality";
4
+ import Metavariable from "../../metavariable";
4
5
  import TypeAssertion from "../../assertion/type";
6
+ import DefinedAssertion from "../../assertion/defined";
7
+ import SubproofAssertion from "../../assertion/subproof";
8
+ import ContainedAssertion from "../../assertion/contained";
9
+ import StatementSubstitution from "../../substitution/statement";
5
10
 
6
11
  import verifyFrame from "../../verify/frame";
7
12
  import verifyJudgement from "../../verify/judgement";
8
13
  import verifyDeclaration from "../../verify/declaration";
9
- import metavariableUnifier from "../../unifier/metavariable";
10
- import verifyDefinedAssertion from "../../verify/assertion/defined";
11
- import verifyContainedAssertion from "../../verify/assertion/contained";
12
14
 
13
15
  import { nodeQuery } from "../../utilities/query";
14
- import { metavariableNameFromMetavariableNode } from "../../utilities/name";
15
- import SubproofAssertion from "../../assertion/subproof";
16
16
 
17
17
  const frameNodeQuery = nodeQuery("/statement/frame!"),
18
18
  equalityNodeQuery = nodeQuery("/statement/equality!"),
@@ -28,16 +28,29 @@ function verifyAsMetavariable(statement, assignments, stated, localContext) {
28
28
  let verifiedAsMetavariable = false;
29
29
 
30
30
  const statementNode = statement.getNode(),
31
- metavariableNode = metavariableNodeQuery(statementNode);
31
+ metavariableNode = metavariableNodeQuery(statementNode),
32
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
32
33
 
33
- if (metavariableNode !== null) {
34
+ if (metavariable !== null) {
34
35
  const statementString = statement.getString();
35
36
 
36
37
  localContext.trace(`Verifying the '${statementString}' statement as a metavariable...`);
37
38
 
38
- const metavariableUnified = unifyMetavariable(metavariableNode, localContext);
39
+ const metavariableVerified = metavariable.verify(localContext);
40
+
41
+ if (metavariableVerified) {
42
+ let substitutionVerified = true;
43
+
44
+ const statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext);
45
+
46
+ if (statementSubstitution !== null) {
47
+ const statementSubstitutionVerified = statementSubstitution.verify(assignments, stated, localContext);
39
48
 
40
- verifiedAsMetavariable = metavariableUnified; ///
49
+ substitutionVerified = statementSubstitutionVerified; ///
50
+ }
51
+
52
+ verifiedAsMetavariable = substitutionVerified; ///
53
+ }
41
54
 
42
55
  if (verifiedAsMetavariable) {
43
56
  localContext.debug(`...verified the '${statementString}' statement as a metavariable.`);
@@ -168,14 +181,15 @@ function verifyAsDefinedAssertion(statement, assignments, stated, localContext)
168
181
  let verifiedAsDefinedAssertion = false;
169
182
 
170
183
  const statementNode = statement.getNode(),
171
- definedAssertionNode = definedAssertionNodeQuery(statementNode);
184
+ definedAssertionNode = definedAssertionNodeQuery(statementNode),
185
+ definedAssertion = DefinedAssertion.fromDefinedAssertionNode(definedAssertionNode, localContext);
172
186
 
173
- if (definedAssertionNode !== null) {
187
+ if (definedAssertion !== null) {
174
188
  const statementString = statement.getString();
175
189
 
176
190
  localContext.trace(`Verifying the '${statementString}' statement as a defined assertion...`);
177
191
 
178
- const definedAssertionVerified = verifyDefinedAssertion(definedAssertionNode, assignments, stated, localContext);
192
+ const definedAssertionVerified = definedAssertion.verify(assignments, stated, localContext);
179
193
 
180
194
  verifiedAsDefinedAssertion = definedAssertionVerified; ///
181
195
 
@@ -215,14 +229,15 @@ function verifyAsContainedAssertion(statement, assignments, stated, localContext
215
229
  let verifiedAsContainedAssertion = false;
216
230
 
217
231
  const statementNode = statement.getNode(),
218
- containedAssertionNode = containedAssertionNodeQuery(statementNode);
232
+ containedAssertionNode = containedAssertionNodeQuery(statementNode),
233
+ containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode, localContext);
219
234
 
220
- if (containedAssertionNode !== null) {
235
+ if (containedAssertion !== null) {
221
236
  const statementString = statement.getString();
222
237
 
223
238
  localContext.trace(`Verifying the '${statementString}' statement as a contained assertion...`);
224
239
 
225
- const containedAssertionVerified = verifyContainedAssertion(containedAssertionNode, assignments, stated, localContext);
240
+ const containedAssertionVerified = containedAssertion.verify(assignments, stated, localContext);
226
241
 
227
242
  verifiedAsContainedAssertion = containedAssertionVerified; ///
228
243
 
@@ -247,30 +262,3 @@ const verifyMixins = [
247
262
  ];
248
263
 
249
264
  export default verifyMixins;
250
-
251
- function unifyMetavariable(metavariableNode, localContext) {
252
- let metavariableUnified;
253
-
254
- const metavariableString = localContext.nodeAsString(metavariableNode);
255
-
256
- localContext.trace(`Unifying the '${metavariableString}' metavariable...`);
257
-
258
- const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
259
- metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
260
-
261
- if (metavariable !== null) {
262
- const metavariableNodeA = metavariableNode; ///
263
-
264
- metavariableNode = metavariable.getNode();
265
-
266
- const metavariableNodeB = metavariableNode; ///
267
-
268
- metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
269
- }
270
-
271
- if (metavariableUnified) {
272
- localContext.debug(`...unified the '${metavariableString}' metavariable.`);
273
- }
274
-
275
- return metavariableUnified;
276
- }
package/src/premise.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  import shim from "./shim";
4
- import LocalContext from "./context/local";
5
- import metaLevelUnifier from "./unifier/metaLevel";
6
4
  import SubproofAssertion from "./assertion/subproof";
7
5
  import UnqualifiedStatement from "./statement/unqualified";
8
6
 
@@ -80,26 +78,15 @@ export default class Premise {
80
78
  unifyStatement(statement, substitutions, localContext) {
81
79
  let statementUnified;
82
80
 
83
- const premise = this, ///
84
- statementString = statement.getString(),
85
- premiseStatement = premise.getStatement(),
86
- premiseStatementString = premiseStatement.getString();
87
-
88
- localContext.trace(`Unifying the '${statementString}' statement with the premise's '${premiseStatementString}' statement...`);
81
+ const statementString = statement.getString(),
82
+ premiseString = this.getString();
89
83
 
90
- const statementNode = statement.getNode(),
91
- premiseStatementNode = premiseStatement.getNode(),
92
- nodeA = premiseStatementNode, ///
93
- nodeB = statementNode, ///
94
- fileContextA = this.fileContext, ///
95
- localContextA = LocalContext.fromFileContext(fileContextA),
96
- localContextB = localContext, ///
97
- unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
84
+ localContext.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
98
85
 
99
- statementUnified = unified; ///
86
+ statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, this.fileContext, localContext);
100
87
 
101
88
  if (statementUnified) {
102
- localContext.debug(`...unified the '${statementString}' statement with the premise's '${premiseStatementString}' statement.`);
89
+ localContext.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
103
90
  }
104
91
 
105
92
  return statementUnified;