occam-verify-cli 1.0.708 → 1.0.713

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 (49) hide show
  1. package/lib/element/assertion/property.js +8 -5
  2. package/lib/element/assertion/satisfies.js +7 -3
  3. package/lib/element/combinator.js +20 -20
  4. package/lib/element/conclusion.js +8 -8
  5. package/lib/element/constructor.js +21 -21
  6. package/lib/element/declaration/combinator.js +10 -10
  7. package/lib/element/declaration/constructor.js +10 -10
  8. package/lib/element/deduction.js +8 -8
  9. package/lib/element/frame.js +19 -7
  10. package/lib/element/metavariable.js +1 -1
  11. package/lib/element/proofAssertion/premise.js +29 -24
  12. package/lib/element/proofAssertion/step.js +13 -12
  13. package/lib/element/proofAssertion/supposition.js +30 -25
  14. package/lib/element/reference.js +3 -6
  15. package/lib/element/rule.js +2 -2
  16. package/lib/element/signature.js +7 -7
  17. package/lib/element/statement.js +5 -3
  18. package/lib/element/term.js +8 -9
  19. package/lib/pass/zip.js +23 -0
  20. package/lib/process/unify.js +11 -21
  21. package/lib/process/validate.js +116 -2
  22. package/lib/process/verify.js +6 -125
  23. package/lib/utilities/context.js +1 -9
  24. package/lib/utilities/validation.js +6 -6
  25. package/package.json +1 -1
  26. package/src/element/assertion/property.js +8 -4
  27. package/src/element/assertion/satisfies.js +8 -2
  28. package/src/element/combinator.js +19 -19
  29. package/src/element/conclusion.js +8 -8
  30. package/src/element/constructor.js +21 -20
  31. package/src/element/declaration/combinator.js +9 -9
  32. package/src/element/declaration/constructor.js +9 -9
  33. package/src/element/deduction.js +8 -8
  34. package/src/element/frame.js +26 -7
  35. package/src/element/metavariable.js +0 -1
  36. package/src/element/proofAssertion/premise.js +43 -33
  37. package/src/element/proofAssertion/step.js +15 -13
  38. package/src/element/proofAssertion/supposition.js +44 -34
  39. package/src/element/reference.js +5 -9
  40. package/src/element/rule.js +1 -1
  41. package/src/element/signature.js +6 -6
  42. package/src/element/statement.js +4 -2
  43. package/src/element/term.js +9 -10
  44. package/src/pass/zip.js +19 -0
  45. package/src/process/unify.js +4 -34
  46. package/src/process/validate.js +161 -1
  47. package/src/process/verify.js +2 -166
  48. package/src/utilities/context.js +0 -9
  49. package/src/utilities/validation.js +5 -5
@@ -3,7 +3,7 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { attempt, literally } from "../utilities/context";
6
+ import { literally } from "../utilities/context";
7
7
  import { instantiateReference } from "../process/instantiate";
8
8
  import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
9
9
  import { metavariableFromReferenceNode } from "../utilities/element";
@@ -160,7 +160,7 @@ export default define(class Reference extends Element {
160
160
  const referenceString = this.getString(), ///
161
161
  metavariableString = this.metavariable.getString();
162
162
 
163
- context.trace(`Validating the '${referenceString}' reference's '${metavariableString}' metavariable....'`);
163
+ context.trace(`Validating the '${referenceString}' reference's '${metavariableString}' metavariable...'`);
164
164
 
165
165
  const metaTypeName = REFERENCE_META_TYPE_NAME,
166
166
  referenceMetaType = context.findMetaTypeByMetaTypeName(metaTypeName),
@@ -249,13 +249,9 @@ export default define(class Reference extends Element {
249
249
 
250
250
  context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
251
251
 
252
- const metavariableUnifiesIntrinsically = attempt((specificContext) => {
253
- const generalMetavariable = this.metavariable, ///
254
- specificMetavariable = metavariable, ///
255
- metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
256
-
257
- return metavariableUnifiesIntrinsically;
258
- }, specificContext);
252
+ const generalMetavariable = this.metavariable, ///
253
+ specificMetavariable = metavariable, ///
254
+ metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
259
255
 
260
256
  if (metavariableUnifiesIntrinsically) {
261
257
  metavariableUnifies = true;
@@ -109,7 +109,7 @@ export default define(class Rule extends Element {
109
109
  }, context);
110
110
 
111
111
  if (verifies) {
112
- const rule = this;
112
+ const rule = this; ///
113
113
 
114
114
  context.addRule(rule);
115
115
 
@@ -35,9 +35,9 @@ export default define(class Signature extends Element {
35
35
 
36
36
  context.trace(`Verifying the '${signatureString}' signature...`);
37
37
 
38
- const validates = this.validate(context);
38
+ const signature = this.validate(context);
39
39
 
40
- if (validates) {
40
+ if (signature !== null) {
41
41
  verifies = true;
42
42
  }
43
43
 
@@ -49,7 +49,7 @@ export default define(class Signature extends Element {
49
49
  }
50
50
 
51
51
  validate(context) {
52
- let validates = false;
52
+ let signature = null;
53
53
 
54
54
  const signatureString = this.getString(); ///
55
55
 
@@ -61,14 +61,14 @@ export default define(class Signature extends Element {
61
61
  if (termsValidate) {
62
62
  this.terms = terms;
63
63
 
64
- validates = true;
64
+ signature = this; ///
65
65
  }
66
66
 
67
- if (validates) {
67
+ if (signature) {
68
68
  context.debug(`...validated the '${signatureString}' signature.`);
69
69
  }
70
70
 
71
- return validates
71
+ return signature
72
72
  }
73
73
 
74
74
  validateTerm(term, terms, context) {
@@ -220,9 +220,11 @@ export default define(class Statement extends Element {
220
220
  const metaTypeName = metaType.getName();
221
221
 
222
222
  if (metaTypeName === STATEMENT_META_TYPE_NAME) {
223
- const validates = this.validate(stated, context)
223
+ const statement = this.validate(stated, context)
224
224
 
225
- validatesGivenMetaType = validates; ///
225
+ if (statement !== null) {
226
+ validatesGivenMetaType = true;
227
+ }
226
228
  }
227
229
 
228
230
  if (validatesGivenMetaType) {
@@ -199,20 +199,19 @@ export default define(class Term extends Element {
199
199
 
200
200
  context.trace(`Validating the '${termString}' term given the '${typeString}' type...`);
201
201
 
202
- const validates = this.validate(context, () => {
203
- let validatesForwards;
204
-
205
- const typeEqualToOrSubTypeOfGivenTypeType = this.type.isEqualToOrSubTypeOf(type);
206
-
207
- if (typeEqualToOrSubTypeOfGivenTypeType) {
208
- validatesForwards = true;
209
- }
202
+ const term = this.validate(context, () => {
203
+ const validatesForwards = true;
210
204
 
211
205
  return validatesForwards;
212
206
  });
213
207
 
214
- if (validates) {
215
- validatesGivenType = true;
208
+ if (term !== null) {
209
+ const termType = term.getType(),
210
+ termTypeEqualToOrSubTypeOfGivenTypeType = termType.isEqualToOrSubTypeOf(type);
211
+
212
+ if (termTypeEqualToOrSubTypeOfGivenTypeType) {
213
+ validatesGivenType = true;
214
+ }
216
215
  }
217
216
 
218
217
  if (validatesGivenType) {
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import { ZipPass as ZipPassBase } from "occam-languages";
4
+
5
+ export default class ZipPass extends ZipPassBase {
6
+ run(generalNonTerminalNode, specificNonTerminalNode, ...remainingArguments) {
7
+ let success = false;
8
+
9
+ const specificChildNodes = specificNonTerminalNode.getChildNodes(), ///
10
+ generalChildNodes = generalNonTerminalNode.getChildNodes(), ///
11
+ descended = this.descend(generalChildNodes, specificChildNodes, ...remainingArguments);
12
+
13
+ if (descended) {
14
+ success = true;
15
+ }
16
+
17
+ return success;
18
+ }
19
+ }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- import { ZipPass, queryUtilities } from "occam-languages";
3
+ import { queryUtilities, ZipPass as ZipPassBase } from "occam-languages";
4
+
5
+ import ZipPass from "../pass/zip";
4
6
 
5
7
  import { termFromTermNode, frameFromFrameNode, statementFromStatementNode } from "../utilities/element";
6
8
 
@@ -16,7 +18,7 @@ const typeNodeQuery = nodeQuery("/type"),
16
18
  statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
17
19
  assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!");
18
20
 
19
- class MetaLevelPass extends ZipPass {
21
+ class MetaLevelPass extends ZipPassBase {
20
22
  static maps = [
21
23
  {
22
24
  generalNodeQuery: assumptionMetavariableNodeQuery,
@@ -145,22 +147,6 @@ class MetaLevelPass extends ZipPass {
145
147
  }
146
148
 
147
149
  class CombinatorPass extends ZipPass {
148
- run(combinatorStatementNode, statementNode, stated, generalContext, specificContext) {
149
- let success = false;
150
-
151
- const specificnonTerminalNode = statementNode, ///
152
- generalcnonTerminalNode = combinatorStatementNode, ///
153
- specificChildNodes = specificnonTerminalNode.getChildNodes(), ///
154
- generalcChildNodes = generalcnonTerminalNode.getChildNodes(), ///
155
- descended = this.descend(generalcChildNodes, specificChildNodes, stated, generalContext, specificContext);
156
-
157
- if (descended) {
158
- success = true;
159
- }
160
-
161
- return success;
162
- }
163
-
164
150
  static maps = [
165
151
  {
166
152
  generalNodeQuery: metaTypeNodeQuery,
@@ -250,22 +236,6 @@ class CombinatorPass extends ZipPass {
250
236
  }
251
237
 
252
238
  class ConstructorPass extends ZipPass {
253
- run(constructorTermNode, termNode, generalContext, specificContext) {
254
- let success = false;
255
-
256
- const specificnonTerminalNode = termNode, ///
257
- generalcnonTerminalNode = constructorTermNode, ///
258
- specificChildNodes = specificnonTerminalNode.getChildNodes(), ///
259
- generalcChildNodes = generalcnonTerminalNode.getChildNodes(), ///
260
- descended = this.descend(generalcChildNodes, specificChildNodes, generalContext, specificContext);
261
-
262
- if (descended) {
263
- success = true;
264
- }
265
-
266
- return success;
267
- }
268
-
269
239
  static maps = [
270
240
  {
271
241
  generalNodeQuery: typeNodeQuery,
@@ -149,8 +149,142 @@ class StatementPass extends SimplePass {
149
149
  ];
150
150
  }
151
151
 
152
+ class ConbinatorPass extends SimplePass {
153
+ run(statementNode, context) {
154
+ let success = false;
155
+
156
+ const nonTerminalNode = statementNode, ///
157
+ childNodes = nonTerminalNode.getChildNodes(), ///
158
+ descended = this.descend(childNodes, context);
159
+
160
+ if (descended) {
161
+ success = true;
162
+ }
163
+
164
+ return success;
165
+ }
166
+
167
+ static maps = [
168
+ {
169
+ nodeQuery: statementNodeQuery,
170
+ run: (statementNode, context) => {
171
+ let success = false;
172
+
173
+ let statement;
174
+
175
+ const stated = true;
176
+
177
+ statement = statementFromStatementNode(statementNode, context);
178
+
179
+ statement = statement.validate(stated, context);
180
+
181
+ if (statement !== null) {
182
+ success = true;
183
+ }
184
+
185
+ return success;
186
+ }
187
+ },
188
+ {
189
+ nodeQuery: termNodeQuery,
190
+ run: (termNode, context) => {
191
+ let success = false;
192
+
193
+ let term;
194
+
195
+ term = termFromTermNode(termNode, context);
196
+
197
+ term = term.validate(context, () => { ///
198
+ const validatesForwards = true;
199
+
200
+ return validatesForwards;
201
+ });
202
+
203
+ if (term !== null) {
204
+ success = true;
205
+ }
206
+
207
+ return success;
208
+ }
209
+ },
210
+ {
211
+ nodeQuery: typeNodeQuery,
212
+ run: (typeNode, context) => {
213
+ let success = false;
214
+
215
+ const nominalTypeName = typeNode.getNominalTypeName(),
216
+ typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
217
+
218
+ if (typePresent) {
219
+ success = true;
220
+ }
221
+
222
+ return success;
223
+ }
224
+ }
225
+ ];
226
+ }
227
+
228
+ class ConstructorPass extends SimplePass {
229
+ run(termNode, context) {
230
+ let success = false;
231
+
232
+ const nonTerminalNode = termNode, ///
233
+ childNodes = nonTerminalNode.getChildNodes(), ///
234
+ descended = this.descend(childNodes, context);
235
+
236
+ if (descended) {
237
+ success = true;
238
+ }
239
+
240
+ return success;
241
+ }
242
+
243
+ static maps = [
244
+ {
245
+ nodeQuery: termNodeQuery,
246
+ run: (termNode, context) => {
247
+ let success = false;
248
+
249
+ let term;
250
+
251
+ term = termFromTermNode(termNode, context);
252
+
253
+ term = term.validate(context, () => { ///
254
+ const validatesForwards = true;
255
+
256
+ return validatesForwards;
257
+ });
258
+
259
+ if (term !== null) {
260
+ success = true;
261
+ }
262
+
263
+ return success;
264
+ }
265
+ },
266
+ {
267
+ nodeQuery: typeNodeQuery,
268
+ run: (typeNode, context) => {
269
+ let success = false;
270
+
271
+ const nominalTypeName = typeNode.getNominalTypeName(),
272
+ typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
273
+
274
+ if (typePresent) {
275
+ success = true;
276
+ }
277
+
278
+ return success;
279
+ }
280
+ }
281
+ ];
282
+ }
283
+
152
284
  const termPass = new TermPass(),
153
- statementPass = new StatementPass();
285
+ statementPass = new StatementPass(),
286
+ combinatorPass = new ConbinatorPass(),
287
+ constructorPass = new ConstructorPass();
154
288
 
155
289
  export function validateTerm(termNode, context, validateForwards) {
156
290
  let termValidates = false;
@@ -177,3 +311,29 @@ export function validateStatement(statementNode, context) {
177
311
 
178
312
  return statementValidates;
179
313
  }
314
+
315
+ export function validateTermAsConstructor(term, context) {
316
+ let termValidatesAsConstructor = false;
317
+
318
+ const termNode = term.getNode(),
319
+ success = constructorPass.run(termNode, context);
320
+
321
+ if (success) {
322
+ termValidatesAsConstructor = true;
323
+ }
324
+
325
+ return termValidatesAsConstructor;
326
+ }
327
+
328
+ export function validateStatementAsCombinator(statement, context) {
329
+ let statementValidatesAsCombinator = false;
330
+
331
+ const statementNode = statement.getNode(),
332
+ success = combinatorPass.run(statementNode, context);
333
+
334
+ if (success) {
335
+ statementValidatesAsCombinator = true;
336
+ }
337
+
338
+ return statementValidatesAsCombinator;
339
+ }
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import { AsyncPass, SimplePass, queryUtilities } from "occam-languages"
3
+ import { AsyncPass, queryUtilities } from "occam-languages"
4
4
 
5
- import { termFromTermNode, statementFromStatementNode } from "../utilities/element";
6
5
  import { ruleFromRuleNode,
7
6
  errorFromErrorNode,
8
7
  axiomFromAxiomNode,
@@ -23,15 +22,12 @@ import { ruleFromRuleNode,
23
22
  const { nodeQuery } = queryUtilities;
24
23
 
25
24
  const ruleNodeQuery = nodeQuery("/rule"),
26
- termNodeQuery = nodeQuery("/term"),
27
- typeNodeQuery = nodeQuery("/type"),
28
25
  errorNodeQuery = nodeQuery("/error"),
29
26
  axiomNodeQuery = nodeQuery("/axiom"),
30
27
  lemmaNodeQuery = nodeQuery("/lemma"),
31
28
  sectionNodeQuery = nodeQuery("/section"),
32
29
  theoremNodeQuery = nodeQuery("/theorem"),
33
30
  metaLemmaNodeQuery = nodeQuery("/metaLemma"),
34
- statementNodeQuery = nodeQuery("/statement"),
35
31
  conjectureNodeQuery = nodeQuery("/conjecture"),
36
32
  metatheoremNodeQuery = nodeQuery("/metatheorem"),
37
33
  variableDeclarationNodeQuery = nodeQuery("/variableDeclaration"),
@@ -287,141 +283,7 @@ class TopLevelPass extends AsyncPass {
287
283
  ];
288
284
  }
289
285
 
290
- class ConbinatorPass extends SimplePass {
291
- run(statementNode, context) {
292
- let success = false;
293
-
294
- const nonTerminalNode = statementNode, ///
295
- childNodes = nonTerminalNode.getChildNodes(), ///
296
- descended = this.descend(childNodes, context);
297
-
298
- if (descended) {
299
- success = true;
300
- }
301
-
302
- return success;
303
- }
304
-
305
- static maps = [
306
- {
307
- nodeQuery: statementNodeQuery,
308
- run: (statementNode, context) => {
309
- let success = false;
310
-
311
- let statement;
312
-
313
- const stated = true;
314
-
315
- statement = statementFromStatementNode(statementNode, context);
316
-
317
- statement = statement.validate(stated, context);
318
-
319
- if (statement !== null) {
320
- success = true;
321
- }
322
-
323
- return success;
324
- }
325
- },
326
- {
327
- nodeQuery: termNodeQuery,
328
- run: (termNode, context) => {
329
- let success = false;
330
-
331
- let term;
332
-
333
- term = termFromTermNode(termNode, context);
334
-
335
- term = term.validate(context, () => { ///
336
- const validatesForwards = true;
337
-
338
- return validatesForwards;
339
- });
340
-
341
- if (term !== null) {
342
- success = true;
343
- }
344
-
345
- return success;
346
- }
347
- },
348
- {
349
- nodeQuery: typeNodeQuery,
350
- run: (typeNode, context) => {
351
- let success = false;
352
-
353
- const nominalTypeName = typeNode.getNominalTypeName(),
354
- typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
355
-
356
- if (typePresent) {
357
- success = true;
358
- }
359
-
360
- return success;
361
- }
362
- }
363
- ];
364
- }
365
-
366
- class ConstructorPass extends SimplePass {
367
- run(termNode, context) {
368
- let success = false;
369
-
370
- const nonTerminalNode = termNode, ///
371
- childNodes = nonTerminalNode.getChildNodes(), ///
372
- descended = this.descend(childNodes, context);
373
-
374
- if (descended) {
375
- success = true;
376
- }
377
-
378
- return success;
379
- }
380
-
381
- static maps = [
382
- {
383
- nodeQuery: termNodeQuery,
384
- run: (termNode, context) => {
385
- let success = false;
386
-
387
- let term;
388
-
389
- term = termFromTermNode(termNode, context);
390
-
391
- term = term.validate(context, () => { ///
392
- const validatesForwards = true;
393
-
394
- return validatesForwards;
395
- });
396
-
397
- if (term !== null) {
398
- success = true;
399
- }
400
-
401
- return success;
402
- }
403
- },
404
- {
405
- nodeQuery: typeNodeQuery,
406
- run: (typeNode, context) => {
407
- let success = false;
408
-
409
- const nominalTypeName = typeNode.getNominalTypeName(),
410
- typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
411
-
412
- if (typePresent) {
413
- success = true;
414
- }
415
-
416
- return success;
417
- }
418
- }
419
- ];
420
- }
421
-
422
- const topLevelPass = new TopLevelPass(),
423
- combinatorPass = new ConbinatorPass(),
424
- constructorPass = new ConstructorPass();
286
+ const topLevelPass = new TopLevelPass();
425
287
 
426
288
  export async function verifyFile(fileNode, context) {
427
289
  let fileVerifies = false;
@@ -435,29 +297,3 @@ export async function verifyFile(fileNode, context) {
435
297
 
436
298
  return fileVerifies;
437
299
  }
438
-
439
- export function verifyTermAsConstructor(term, context) {
440
- let termVerifiesAsConstructor = false;
441
-
442
- const termNode = term.getNode(),
443
- success = constructorPass.run(termNode, context);
444
-
445
- if (success) {
446
- termVerifiesAsConstructor = true;
447
- }
448
-
449
- return termVerifiesAsConstructor;
450
- }
451
-
452
- export function verifyStatementAsCombinator(statement, context) {
453
- let statementVerifiesAsCombinator = false;
454
-
455
- const statementNode = statement.getNode(),
456
- success = combinatorPass.run(statementNode, context);
457
-
458
- if (success) {
459
- statementVerifiesAsCombinator = true;
460
- }
461
-
462
- return statementVerifiesAsCombinator;
463
- }
@@ -46,14 +46,6 @@ export async function asyncScope(innerFunction, context) {
46
46
  return await innerFunction(context);
47
47
  }
48
48
 
49
- export async function asyncAttempt(innerFunction, context) {
50
- const ephemeralContext = EphemeralContext.fromNothing(context);
51
-
52
- context = ephemeralContext; ///
53
-
54
- return await innerFunction(context);
55
- }
56
-
57
49
  export async function asyncLiminally(innerFunction, context) {
58
50
  const liminalContext = LiminalContext.fromNothing(context);
59
51
 
@@ -61,4 +53,3 @@ export async function asyncLiminally(innerFunction, context) {
61
53
 
62
54
  return await innerFunction(context);
63
55
  }
64
-
@@ -73,7 +73,7 @@ function unifyTermWithBracketedConstructor(term, context, validateForwards) {
73
73
  }
74
74
 
75
75
  function validateStatementAsMetavariable(statement, stated, context) {
76
- let statementValidatesAsMetavariableAndSubstitution = false;
76
+ let statementValidatesAsMetavariable = false;
77
77
 
78
78
  const statementNode = statement.getNode(),
79
79
  metavariableNode = statementNode.getMetavariableNode();
@@ -87,7 +87,7 @@ function validateStatementAsMetavariable(statement, stated, context) {
87
87
  metavariable = context.findMetavariableByMetavariableName(metavariableName);
88
88
 
89
89
  if (metavariable !== null) {
90
- statementValidatesAsMetavariableAndSubstitution = true;
90
+ statementValidatesAsMetavariable = true;
91
91
 
92
92
  const { TermSubstitution, FrameSubstitution } = elements,
93
93
  frameSubstitution = FrameSubstitution.fromStatement(statement, context),
@@ -104,17 +104,17 @@ function validateStatementAsMetavariable(statement, stated, context) {
104
104
  substitution = substitution.validate(generalContext, specificContext);
105
105
 
106
106
  if (substitution === null) {
107
- statementValidatesAsMetavariableAndSubstitution = false;
107
+ statementValidatesAsMetavariable = false;
108
108
  }
109
109
  }
110
110
  }
111
111
 
112
- if (statementValidatesAsMetavariableAndSubstitution) {
112
+ if (statementValidatesAsMetavariable) {
113
113
  context.debug(`...validated the '${statementString}' statement as a metavariable.`);
114
114
  }
115
115
  }
116
116
 
117
- return statementValidatesAsMetavariableAndSubstitution;
117
+ return statementValidatesAsMetavariable;
118
118
  }
119
119
 
120
120
  function unifyStatementWithCombinators(statement, stated, context) {