occam-verify-cli 0.0.1059 → 0.0.1063

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 (45) hide show
  1. package/lib/assertion/contained.js +185 -0
  2. package/lib/assertion/defined.js +187 -0
  3. package/lib/assertion/subproof.js +3 -3
  4. package/lib/assertion/type.js +13 -6
  5. package/lib/context/release.js +5 -5
  6. package/lib/declaration.js +6 -50
  7. package/lib/equality.js +6 -7
  8. package/lib/equivalence.js +3 -2
  9. package/lib/frame.js +160 -64
  10. package/lib/metavariable.js +20 -7
  11. package/lib/mixins/statement/verify.js +24 -32
  12. package/lib/statement.js +58 -4
  13. package/lib/substitution/statement.js +17 -2
  14. package/lib/term.js +46 -3
  15. package/lib/variable.js +6 -2
  16. package/lib/verifier/intrinsicLevel.js +4 -4
  17. package/lib/verifier/metaLevel.js +4 -4
  18. package/lib/verifier/substitution.js +161 -0
  19. package/lib/verifier/topLevel.js +4 -4
  20. package/package.json +3 -3
  21. package/src/assertion/contained.js +172 -0
  22. package/src/assertion/defined.js +188 -0
  23. package/src/assertion/subproof.js +3 -2
  24. package/src/assertion/type.js +18 -7
  25. package/src/context/release.js +5 -7
  26. package/src/declaration.js +49 -49
  27. package/src/equality.js +7 -8
  28. package/src/equivalence.js +3 -1
  29. package/src/frame.js +204 -59
  30. package/src/metavariable.js +35 -11
  31. package/src/mixins/statement/verify.js +30 -42
  32. package/src/statement.js +85 -4
  33. package/src/substitution/statement.js +22 -2
  34. package/src/term.js +61 -3
  35. package/src/variable.js +7 -2
  36. package/src/verifier/intrinsicLevel.js +3 -3
  37. package/src/verifier/metaLevel.js +3 -3
  38. package/src/verifier/substitution.js +75 -0
  39. package/src/verifier/topLevel.js +3 -3
  40. package/lib/verify/assertion/contained.js +0 -107
  41. package/lib/verify/assertion/defined.js +0 -98
  42. package/lib/verify/assertion/subproof.js +0 -16
  43. package/src/verify/assertion/contained.js +0 -134
  44. package/src/verify/assertion/defined.js +0 -120
  45. package/src/verify/assertion/subproof.js +0 -9
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";
@@ -14,7 +15,7 @@ const argumentNodeQuery = nodeQuery("/metavariable/argument"),
14
15
  metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
15
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,7 +172,7 @@ export default class Metavariable {
159
172
 
160
173
  const statementString = statement.getString(),
161
174
  substitutionString = substitution.getString(),
162
- metavariableString = this.string;
175
+ metavariableString = this.string; ///
163
176
 
164
177
  localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable givne the '${substitutionString}' substitution...`);
165
178
 
@@ -230,12 +243,17 @@ export default class Metavariable {
230
243
  }
231
244
 
232
245
  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);
246
+ let metavariable = null;
247
+
248
+ if (metavariableNode !== null) {
249
+ const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
250
+ node = metavariableNode, ///
251
+ name = metavariableName, ///
252
+ string = fileContext.nodeAsString(node),
253
+ metaType = null;
254
+
255
+ metavariable = new Metavariable(fileContext, string, node, name, metaType);
256
+ }
239
257
 
240
258
  return metavariable;
241
259
  }
@@ -257,6 +275,12 @@ export default class Metavariable {
257
275
  }
258
276
  }
259
277
 
278
+ Object.assign(shim, {
279
+ Metavariable
280
+ });
281
+
282
+ export default Metavariable;
283
+
260
284
  function metaTypeFromJSON(json, fileContext) {
261
285
  let { metaType } = json;
262
286
 
@@ -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/statement.js CHANGED
@@ -6,9 +6,14 @@ import verifyMixins from "./mixins/statement/verify";
6
6
  import StatementSubstitution from "./substitution/statement";
7
7
  import statementAsCombinatorVerifier from "./verifier/statementAsCombinator";
8
8
 
9
+ import { nodeQuery, nodesQuery } from "./utilities/query";
9
10
  import { STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
10
11
  import { statementNodeFromStatementString } from "./utilities/node";
11
12
 
13
+ const statementNodeQuery = nodeQuery("/*//statement"),
14
+ statementVariableNodesQuery = nodesQuery("/statement//variable"),
15
+ statementMetavariableNodesQuery = nodesQuery("/statement//metavariable");
16
+
12
17
  class Statement {
13
18
  constructor(string, node, substitution) {
14
19
  this.string = string;
@@ -36,6 +41,60 @@ class Statement {
36
41
  return equalTo;
37
42
  }
38
43
 
44
+ isVariableContained(variable, localContext) {
45
+ let variableContained;
46
+
47
+ const variableString = variable.getString(),
48
+ statementString = this.string; ///
49
+
50
+ localContext.trace(`The '${variableString}' variable is contained in hte '${statementString}' statement...`);
51
+
52
+ const variableNode = variable.getNode(),
53
+ statementNode = this.node,
54
+ statementVariableNodes = statementVariableNodesQuery(statementNode);
55
+
56
+ variableContained = statementVariableNodes.some((statementVariableNode) => { ///
57
+ const variableNodeMatchesStatementVariableNode = variableNode.match(statementVariableNode);
58
+
59
+ if (variableNodeMatchesStatementVariableNode) {
60
+ return true;
61
+ }
62
+ });
63
+
64
+ if (variableContained) {
65
+ localContext.debug(`...the '${variableString}' variable is contained in hte '${statementString}' statement.`);
66
+ }
67
+
68
+ return variableContained;
69
+ }
70
+
71
+ isMetavariableContained(metavariable, localContext) {
72
+ let metavariableContained;
73
+
74
+ const metavariableString = metavariable.getString(),
75
+ statementString = this.string; ///
76
+
77
+ localContext.trace(`The '${metavariableString}' metavariable is contained in hte '${statementString}' statement...`);
78
+
79
+ const metavariableNode = metavariable.getNode(),
80
+ statementNode = this.node,
81
+ statementMetavariableNodes = statementMetavariableNodesQuery(statementNode);
82
+
83
+ metavariableContained = statementMetavariableNodes.some((statementMetavariableNode) => { ///
84
+ const metavariableNodeMatchesStatementMetavariableNode = metavariableNode.match(statementMetavariableNode);
85
+
86
+ if (metavariableNodeMatchesStatementMetavariableNode) {
87
+ return true;
88
+ }
89
+ });
90
+
91
+ if (metavariableContained) {
92
+ localContext.debug(`...the '${metavariableString}' metavariable is contained in hte '${statementString}' statement.`);
93
+ }
94
+
95
+ return metavariableContained;
96
+ }
97
+
39
98
  verify(assignments, stated, localContext) {
40
99
  let verified = false;
41
100
 
@@ -96,7 +155,7 @@ class Statement {
96
155
  const metaTypeString = metaType.getString(),
97
156
  statementString = this.string; ///
98
157
 
99
- localContext.trace(`Verifying the '${statementString}' given the '${metaTypeString}' meta-type...`);
158
+ localContext.trace(`Verifying the '${statementString}' statement given the '${metaTypeString}' meta-type...`);
100
159
 
101
160
  const metaTypeName = metaType.getName();
102
161
 
@@ -107,7 +166,7 @@ class Statement {
107
166
  }
108
167
 
109
168
  if (verifiedGivenMetaType) {
110
- localContext.debug(`...verified the '${statementString}' given the '${metaTypeString}' meta-type.`);
169
+ localContext.debug(`...verified the '${statementString}' statement given the '${metaTypeString}' meta-type.`);
111
170
  }
112
171
 
113
172
  return verifiedGivenMetaType;
@@ -162,13 +221,35 @@ class Statement {
162
221
 
163
222
  return statement;
164
223
  }
224
+
225
+ static fromDefinedAssertionNode(definedAssertionNode, localContext) {
226
+ const statementNode = statementNodeQuery(definedAssertionNode),
227
+ node = statementNode, ///
228
+ string = localContext.nodeAsString(node),
229
+ statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext),
230
+ substitution = statementSubstitution, ///
231
+ statement = new Statement(string, node, substitution);
232
+
233
+ return statement;
234
+ }
235
+
236
+ static fromContainedAssertionNode(containedAssertionNode, localContext) {
237
+ const statementNode = statementNodeQuery(containedAssertionNode),
238
+ node = statementNode, ///
239
+ string = localContext.nodeAsString(node),
240
+ statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext),
241
+ substitution = statementSubstitution, ///
242
+ statement = new Statement(string, node, substitution);
243
+
244
+ return statement;
245
+ }
165
246
  }
166
247
 
248
+ Object.assign(Statement.prototype, unifyMixins);
249
+
167
250
  Object.assign(shim, {
168
251
  Statement
169
252
  });
170
253
 
171
- Object.assign(Statement.prototype, unifyMixins);
172
-
173
254
  export default Statement;
174
255