occam-verify-cli 1.0.747 → 1.0.757

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 (123) hide show
  1. package/lib/context/branching.js +56 -0
  2. package/lib/context/ephemeral.js +10 -1
  3. package/lib/context/file/nominal.js +5 -10
  4. package/lib/context/scoped.js +6 -5
  5. package/lib/context/synthetic.js +7 -3
  6. package/lib/context.js +9 -1
  7. package/lib/element/assertion/contained.js +7 -7
  8. package/lib/element/assertion/defined.js +7 -7
  9. package/lib/element/assertion/property.js +3 -3
  10. package/lib/element/assertion/satisfies.js +2 -2
  11. package/lib/element/assertion/subproof.js +111 -14
  12. package/lib/element/assertion/type.js +7 -7
  13. package/lib/element/assumption.js +21 -33
  14. package/lib/element/combinator.js +4 -4
  15. package/lib/element/conclusion.js +3 -7
  16. package/lib/element/constructor/bracketed.js +9 -8
  17. package/lib/element/constructor.js +9 -5
  18. package/lib/element/deduction.js +17 -20
  19. package/lib/element/derivation.js +4 -4
  20. package/lib/element/equality.js +12 -11
  21. package/lib/element/equivalence.js +3 -3
  22. package/lib/element/frame.js +2 -2
  23. package/lib/element/hypothesis.js +2 -2
  24. package/lib/element/judgement.js +2 -2
  25. package/lib/element/label.js +4 -4
  26. package/lib/element/metavariable.js +65 -25
  27. package/lib/element/parameter.js +2 -2
  28. package/lib/element/procedureCall.js +2 -2
  29. package/lib/element/procedureReference.js +2 -2
  30. package/lib/element/proof.js +7 -7
  31. package/lib/element/proofAssertion/premise.js +12 -18
  32. package/lib/element/proofAssertion/step.js +3 -3
  33. package/lib/element/proofAssertion/supposition.js +13 -19
  34. package/lib/element/property.js +2 -2
  35. package/lib/element/propertyRelation.js +3 -3
  36. package/lib/element/reference.js +11 -9
  37. package/lib/element/rule.js +2 -2
  38. package/lib/element/signature.js +3 -3
  39. package/lib/element/statement.js +100 -59
  40. package/lib/element/subDerivation.js +4 -4
  41. package/lib/element/subproof.js +7 -7
  42. package/lib/element/substitution/frame.js +8 -8
  43. package/lib/element/substitution/metaLevel.js +7 -7
  44. package/lib/element/substitution/reference.js +7 -7
  45. package/lib/element/substitution/statement.js +73 -60
  46. package/lib/element/substitution/term.js +10 -10
  47. package/lib/element/term.js +17 -14
  48. package/lib/element/topLevelAssertion/axiom.js +15 -13
  49. package/lib/element/topLevelAssertion.js +2 -5
  50. package/lib/element/topLevelMetaAssertion.js +27 -3
  51. package/lib/element/type.js +2 -2
  52. package/lib/element/typePrefix.js +2 -2
  53. package/lib/element/variable.js +6 -3
  54. package/lib/process/unify.js +51 -9
  55. package/lib/process/validate.js +5 -5
  56. package/lib/utilities/context.js +28 -20
  57. package/lib/utilities/element.js +2 -2
  58. package/lib/utilities/instance.js +3 -3
  59. package/lib/utilities/releaseContext.js +3 -3
  60. package/lib/utilities/string.js +2 -2
  61. package/lib/utilities/validation.js +13 -5
  62. package/package.json +3 -3
  63. package/src/context/branching.js +59 -0
  64. package/src/context/ephemeral.js +12 -0
  65. package/src/context/file/nominal.js +4 -12
  66. package/src/context/scoped.js +6 -4
  67. package/src/context/synthetic.js +9 -2
  68. package/src/context.js +14 -0
  69. package/src/element/assertion/contained.js +8 -8
  70. package/src/element/assertion/defined.js +7 -7
  71. package/src/element/assertion/property.js +4 -4
  72. package/src/element/assertion/satisfies.js +2 -2
  73. package/src/element/assertion/subproof.js +191 -18
  74. package/src/element/assertion/type.js +7 -7
  75. package/src/element/assumption.js +21 -52
  76. package/src/element/combinator.js +4 -4
  77. package/src/element/conclusion.js +3 -10
  78. package/src/element/constructor/bracketed.js +9 -7
  79. package/src/element/constructor.js +11 -5
  80. package/src/element/deduction.js +17 -23
  81. package/src/element/derivation.js +4 -3
  82. package/src/element/equality.js +16 -14
  83. package/src/element/equivalence.js +3 -3
  84. package/src/element/frame.js +2 -2
  85. package/src/element/hypothesis.js +2 -2
  86. package/src/element/judgement.js +2 -2
  87. package/src/element/label.js +4 -4
  88. package/src/element/metavariable.js +96 -32
  89. package/src/element/parameter.js +2 -2
  90. package/src/element/procedureCall.js +2 -2
  91. package/src/element/procedureReference.js +2 -2
  92. package/src/element/proof.js +8 -8
  93. package/src/element/proofAssertion/premise.js +22 -32
  94. package/src/element/proofAssertion/step.js +3 -3
  95. package/src/element/proofAssertion/supposition.js +27 -36
  96. package/src/element/property.js +2 -2
  97. package/src/element/propertyRelation.js +3 -3
  98. package/src/element/reference.js +11 -9
  99. package/src/element/rule.js +2 -2
  100. package/src/element/signature.js +3 -3
  101. package/src/element/statement.js +154 -88
  102. package/src/element/subDerivation.js +4 -3
  103. package/src/element/subproof.js +6 -6
  104. package/src/element/substitution/frame.js +8 -8
  105. package/src/element/substitution/metaLevel.js +7 -7
  106. package/src/element/substitution/reference.js +7 -7
  107. package/src/element/substitution/statement.js +99 -76
  108. package/src/element/substitution/term.js +10 -10
  109. package/src/element/term.js +22 -16
  110. package/src/element/topLevelAssertion/axiom.js +20 -16
  111. package/src/element/topLevelAssertion.js +2 -4
  112. package/src/element/topLevelMetaAssertion.js +42 -3
  113. package/src/element/type.js +3 -2
  114. package/src/element/typePrefix.js +2 -2
  115. package/src/element/variable.js +12 -3
  116. package/src/process/unify.js +78 -9
  117. package/src/process/validate.js +4 -4
  118. package/src/utilities/context.js +20 -12
  119. package/src/utilities/element.js +2 -2
  120. package/src/utilities/instance.js +3 -3
  121. package/src/utilities/releaseContext.js +1 -1
  122. package/src/utilities/string.js +3 -3
  123. package/src/utilities/validation.js +16 -4
@@ -3,7 +3,7 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { literally } from "../utilities/context";
6
+ import { instantiate } from "../utilities/context";
7
7
  import { instantiateTypePrefix } from "../process/instantiate";
8
8
  import { nameFromTypePrefixNode } from "../utilities/element";
9
9
 
@@ -43,7 +43,7 @@ export default define(class TypePrefix extends Element {
43
43
  static name = "TypePrefix";
44
44
 
45
45
  static fromJSON(json, context) {
46
- const typePrefix = literally((context) => {const { string } = json,
46
+ const typePrefix = instantiate((context) => {const { string } = json,
47
47
  typePrefixNode = instantiateTypePrefix(string, context),
48
48
  node = typePrefixNode, ///
49
49
  name = nameFromTypePrefixNode(typePrefixNode, context);
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
5
5
  import elements from "../elements";
6
6
 
7
7
  import { define } from "../elements";
8
- import { literally } from "../utilities/context";
8
+ import { instantiate } from "../utilities/context";
9
9
  import { instantiateVariable } from "../process/instantiate";
10
10
  import {identifierFromVarialbeNode, variableFromVariableNode} from "../utilities/element";
11
11
  import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
@@ -82,7 +82,11 @@ export default define(class Variable extends Element {
82
82
  variable = context.findVariableByVariableIdentifier(variableIdentifier);
83
83
 
84
84
  if (variable !== null) {
85
- const type = variable.getType();
85
+ const type = variable.getType(),
86
+ typeString = type.getString(),
87
+ variableString = this.getString(); ///
88
+
89
+ context.trace(`Setting the '${variableString}' variable's type to the '${typeString}' type.`);
86
90
 
87
91
  this.type = type;
88
92
 
@@ -122,6 +126,11 @@ export default define(class Variable extends Element {
122
126
  const substitutionComparesToTerm = substitution.compareTerm(term, context);
123
127
 
124
128
  if (substitutionComparesToTerm) {
129
+ const termSubstitution = substitution, ///
130
+ termSubstitutionString = termSubstitution.getString();
131
+
132
+ context.trace(`The '${termSubstitutionString}' term substitution is already present.`);
133
+
125
134
  termUnifies = true;
126
135
  }
127
136
  } else {
@@ -180,7 +189,7 @@ export default define(class Variable extends Element {
180
189
  static name = "Variable";
181
190
 
182
191
  static fromJSON(json, context) {
183
- const variable = literally((context) => {
192
+ const variable = instantiate((context) => {
184
193
  const { string } = json,
185
194
  variableNode = instantiateVariable(string, context),
186
195
  node = variableNode, ///
@@ -223,10 +223,13 @@ class CombinatorPass extends ZipPass {
223
223
 
224
224
  context = specificContext; ///
225
225
 
226
- const term = termFromTermNode(termNode, context),
227
- termValidatesGivenType = term.validateGivenType(type, context);
226
+ let term;
228
227
 
229
- if (termValidatesGivenType) {
228
+ term = termFromTermNode(termNode, context);
229
+
230
+ term = term.validateGivenType(type, context);
231
+
232
+ if (term !== null) {
230
233
  success = true;
231
234
  }
232
235
 
@@ -257,10 +260,13 @@ class ConstructorPass extends ZipPass {
257
260
  if (type !== null) {
258
261
  context = specificContext; ///
259
262
 
260
- const term = termFromTermNode(termNode, context),
261
- termValidatesGivenType = term.validateGivenType(type, context);
263
+ let term;
264
+
265
+ term = termFromTermNode(termNode, context);
262
266
 
263
- if (termValidatesGivenType) {
267
+ term = term.validateGivenType(type, context);
268
+
269
+ if (term !== null) {
264
270
  success = true;
265
271
  }
266
272
  }
@@ -285,9 +291,71 @@ class MetavariablePass extends ZipPass {
285
291
  type = generalContext.findTypeByNominalTypeName(nominalTypeName),
286
292
  context = specificContext, ///
287
293
  term = context.findTermByTermNode(termNode),
288
- termValidatesGivenType = term.validateGivenType(type, context);
294
+ termType = term.getType(),
295
+ termTypeEqualToOrSubTypeOfGivenTypeType = termType.isEqualToOrSubTypeOf(type);
289
296
 
290
- if (termValidatesGivenType) {
297
+ if (termTypeEqualToOrSubTypeOfGivenTypeType) {
298
+ success = true;
299
+ }
300
+
301
+ return success;
302
+ }
303
+ }
304
+ ];
305
+ }
306
+
307
+ class SubstitutionPass extends ZipPass {
308
+ static maps = [
309
+ {
310
+ generalNodeQuery: frameAMetavariableNodeQuery,
311
+ specificNodeQuery: frameNodeQuery,
312
+ run: (generalFrameMetavariableNode, specificFrameNode, generalContext, specificContext) => {
313
+ let success = false;
314
+
315
+ const frameNode = specificFrameNode, ///
316
+ metavariableNode = generalFrameMetavariableNode, ///
317
+ metavariableName = metavariableNode.getMetavariableName();
318
+
319
+ let context;
320
+
321
+ context = generalContext; ///
322
+
323
+ const metavariable = context.findMetavariableByMetavariableName(metavariableName);
324
+
325
+ context = specificContext; ///
326
+
327
+ const frame = context.findFrameByFrameNode(frameNode),
328
+ frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
329
+
330
+ if (frameUnifies) {
331
+ success = true;
332
+ }
333
+
334
+ return success;
335
+ }
336
+ },
337
+ {
338
+ generalNodeQuery: termVariableNodeQuery,
339
+ specificNodeQuery: termNodeQuery,
340
+ run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
341
+ let success = false;
342
+
343
+ const termNode = specificTermNode, ///
344
+ variableNode = generalTermVariableNode, ///
345
+ variableIdentifier = variableNode.getVariableIdentifier();
346
+
347
+ let context;
348
+
349
+ context = generalContext; ///
350
+
351
+ const variable = context.findVariableByVariableIdentifier(variableIdentifier);
352
+
353
+ context = specificContext; ///
354
+
355
+ const term = context.findTermByTermNode(termNode),
356
+ termUnifies = variable.unifyTerm(term, generalContext, specificContext);
357
+
358
+ if (termUnifies) {
291
359
  success = true;
292
360
  }
293
361
 
@@ -334,6 +402,7 @@ const metaLevelPass = new MetaLevelPass(),
334
402
  combinatorPass = new CombinatorPass(),
335
403
  constructorPass = new ConstructorPass(),
336
404
  metavariablePass = new MetavariablePass(),
405
+ substitutionPass = new SubstitutionPass(),
337
406
  intrinsicLevelPass = new IntrinsicLevelPass();
338
407
 
339
408
  export function unifyStatement(generalStatement, specificStatement, generalContext, specificContext) {
@@ -359,7 +428,7 @@ export function unifySubstitution(generalSubstitution, specificSubstitution, gen
359
428
  specificSubstitutionNode = specificSubstitution.getNode(),
360
429
  generalNode = generalSubstitutionNode, ///
361
430
  specificNode = specificSubstitutionNode, ///
362
- success = metaLevelPass.run(generalNode, specificNode, generalContext, specificContext);
431
+ success = substitutionPass.run(generalNode, specificNode, generalContext, specificContext);
363
432
 
364
433
  if (success) {
365
434
  substitutionUnifies = true;
@@ -11,7 +11,7 @@ const termNodeQuery = nodeQuery("/term"),
11
11
  typeNodeQuery = nodeQuery("/type"),
12
12
  statementNodeQuery = nodeQuery("/statement");
13
13
 
14
- class ConbinatorPass extends SimplePass {
14
+ class CombinatorPass extends SimplePass {
15
15
  run(statementNode, context) {
16
16
  let success = false;
17
17
 
@@ -56,7 +56,7 @@ class ConbinatorPass extends SimplePass {
56
56
 
57
57
  term = termFromTermNode(termNode, context);
58
58
 
59
- term = term.validate(context, () => { ///
59
+ term = term.validate(context, (term) => { ///
60
60
  const validatesForwards = true;
61
61
 
62
62
  return validatesForwards;
@@ -112,7 +112,7 @@ class ConstructorPass extends SimplePass {
112
112
 
113
113
  term = termFromTermNode(termNode, context);
114
114
 
115
- term = term.validate(context, () => { ///
115
+ term = term.validate(context, (term) => { ///
116
116
  const validatesForwards = true;
117
117
 
118
118
  return validatesForwards;
@@ -143,7 +143,7 @@ class ConstructorPass extends SimplePass {
143
143
  ];
144
144
  }
145
145
 
146
- const combinatorPass = new ConbinatorPass(),
146
+ const combinatorPass = new CombinatorPass(),
147
147
  constructorPass = new ConstructorPass();
148
148
 
149
149
  export function validateTermAsConstructor(term, context) {
@@ -5,6 +5,22 @@ import LiminalContext from "../context/liminal";
5
5
  import LiteralContext from "../context/literal";
6
6
  import EphemeralContext from "../context/ephemeral";
7
7
  import SyntheticContext from "../context/synthetic";
8
+ import BranchingContext from "../context/branching";
9
+
10
+ export function join(innerFunction, ...contexts) {
11
+ const syntheticContext = SyntheticContext.fromContexts(...contexts),
12
+ context = syntheticContext; ///
13
+
14
+ return innerFunction(context);
15
+ }
16
+
17
+ export function choose(innerFunction, context) {
18
+ const branchingContext = BranchingContext.fromNothing(context);
19
+
20
+ context = branchingContext; ///
21
+
22
+ return innerFunction(context);
23
+ }
8
24
 
9
25
  export function attempt(innerFunction, context) {
10
26
  const ephemeralContext = EphemeralContext.fromNothing(context);
@@ -14,7 +30,7 @@ export function attempt(innerFunction, context) {
14
30
  return innerFunction(context);
15
31
  }
16
32
 
17
- export function liminally(innerFunction, context) {
33
+ export function reconcile(innerFunction, context) {
18
34
  const liminalContext = LiminalContext.fromNothing(context);
19
35
 
20
36
  context = liminalContext; ///
@@ -22,7 +38,7 @@ export function liminally(innerFunction, context) {
22
38
  return innerFunction(context);
23
39
  }
24
40
 
25
- export function literally(innerFunction, context) {
41
+ export function instantiate(innerFunction, context) {
26
42
  const literalContext = LiteralContext.fromNothing(context);
27
43
 
28
44
  context = literalContext; ///
@@ -30,15 +46,7 @@ export function literally(innerFunction, context) {
30
46
  return innerFunction(context);
31
47
  }
32
48
 
33
- export function synthetically(innerFunction, contexts, context) {
34
- const syntheticContext = SyntheticContext.fromContexts(contexts, context);
35
-
36
- context = syntheticContext; ///
37
-
38
- return innerFunction(context);
39
- }
40
-
41
- export async function asyncScope(innerFunction, metaLevelSubstitutions, context) {
49
+ export async function asyncRestrict(innerFunction, metaLevelSubstitutions, context) {
42
50
  if (context === undefined) {
43
51
  context = metaLevelSubstitutions; ///
44
52
 
@@ -52,7 +60,7 @@ export async function asyncScope(innerFunction, metaLevelSubstitutions, context)
52
60
  return await innerFunction(context);
53
61
  }
54
62
 
55
- export async function asyncLiminally(innerFunction, context) {
63
+ export async function asyncReconcile(innerFunction, context) {
56
64
  const liminalContext = LiminalContext.fromNothing(context);
57
65
 
58
66
  context = liminalContext; ///
@@ -2,7 +2,7 @@
2
2
 
3
3
  import elements from "../elements";
4
4
 
5
- import { literally } from "../utilities/context";
5
+ import { instantiate } from "../utilities/context";
6
6
  import { baseTypeFromNothing } from "../utilities/type";
7
7
  import { instantiateReference } from "../process/instantiate";
8
8
  import { equivalenceStringFromTerms,
@@ -1363,7 +1363,7 @@ export function metavariableFromReferenceNode(referenceNode, context) {
1363
1363
  export function referenceFromMetavariableNode(metavariableNode, context) {
1364
1364
  const metavariableString = context.nodeAsString(metavariableNode);
1365
1365
 
1366
- return literally((context) => {
1366
+ return instantiate((context) => {
1367
1367
  const referenceString = metavariableString, ///
1368
1368
  string = referenceString, ///
1369
1369
  referenceNode = instantiateReference(string, context),
@@ -2,7 +2,7 @@
2
2
 
3
3
  import nominalContext from "../context/nominal";
4
4
 
5
- import { literally } from "../utilities/context";
5
+ import { instantiate } from "../utilities/context";
6
6
  import { BASE_TYPE_SYMBOL } from "../constants";
7
7
  import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
8
8
  import { instantiateCombinator, instantiateConstructor } from "../process/instantiate";
@@ -15,7 +15,7 @@ export function bracketedCombinatorFromNothing() {
15
15
  if (bracketedCombinator === null) {
16
16
  const context = nominalContext; ///
17
17
 
18
- bracketedCombinator = literally((context) => {
18
+ bracketedCombinator = instantiate((context) => {
19
19
  const bracketedCombinatorString = `(${STATEMENT_META_TYPE_NAME})`,
20
20
  string = bracketedCombinatorString, ///
21
21
  combinatorNode = instantiateCombinator(string, context),
@@ -33,7 +33,7 @@ export function bracketedConstructorFromNothing() {
33
33
  if (bracketedConstructor === null) {
34
34
  const context = nominalContext; ///
35
35
 
36
- bracketedConstructor = literally((context) => {
36
+ bracketedConstructor = instantiate((context) => {
37
37
  const bracketedConstructorString = `(${BASE_TYPE_SYMBOL})`,
38
38
  string = bracketedConstructorString, ///
39
39
  constructorNode = instantiateConstructor(string, context),
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { releaseContextUtilities } from "occam-languages";
4
- import { fileSystemUtilities as occamFileSystemUtilities } from "occam-file-system";
4
+ import { fileSystemUtilities as occamFileSystemUtilities } from "occam-server";
5
5
  import { pathUtilities, fileSystemUtilities as necessaryFileSystemUtilities } from "necessary";
6
6
 
7
7
  const { loadProject } = occamFileSystemUtilities,
@@ -168,10 +168,10 @@ export function sectionStringFromHypothesesTopLevelAssertion(hypotheses, axiom,
168
168
  }
169
169
 
170
170
  export function subproofStringFromSuppositionsAndSubDerivation(suppositions, subDerivation) {
171
- const lastProofAssertion = subDerivation.getLastProofAssertion(),
171
+ const lastStep = subDerivation.getLastStep(),
172
172
  suppositionsString = suppositionsStringFromSuppositions(suppositions),
173
- lastProofAssertionString = lastProofAssertion.getString(),
174
- subproofString = `[${suppositionsString}]...${lastProofAssertionString}`;
173
+ lastStepString = lastStep.getString(),
174
+ subproofString = `[${suppositionsString}]...${lastStepString}`;
175
175
 
176
176
  return subproofString;
177
177
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  import elements from "../elements";
4
4
 
5
+ import { choose } from "./context";
5
6
  import { variableFromTerm } from "../utilities/term";
6
7
  import { bracketedConstructorFromNothing, bracketedCombinatorFromNothing } from "../utilities/instance";
7
8
  import { equalityFromStatement,
@@ -29,11 +30,14 @@ function validateTermAsVariable(term, context, validateForwards) {
29
30
  variable = variable.validate(context);
30
31
 
31
32
  if (variable !== null) {
32
- const type = variable.getType();
33
+ const type = variable.getType(),
34
+ typeString = type.getString();
35
+
36
+ context.trace(`Setting the '${termString}' term's type to the '${typeString}' type.`);
33
37
 
34
38
  term.setType(type);
35
39
 
36
- const validatesForwards = validateForwards();
40
+ const validatesForwards = validateForwards(term);
37
41
 
38
42
  if (validatesForwards) {
39
43
  termValidatesAsVariable = true;
@@ -54,9 +58,17 @@ function unifyTermWithConstructors(term, context, validateForwards) {
54
58
  const constructors = context.getConstructors();
55
59
 
56
60
  termUnifiesWithConstructors = constructors.some((constructor) => {
57
- const unifiesWithConstructor = constructor.unifyTerm(term, context, validateForwards);
61
+ let termUnifies;
62
+
63
+ choose((context) => {
64
+ termUnifies = constructor.unifyTerm(term, context, validateForwards);
65
+
66
+ if (termUnifies) {
67
+ context.commit();
68
+ }
69
+ }, context);
58
70
 
59
- if (unifiesWithConstructor) {
71
+ if (termUnifies) {
60
72
  return true;
61
73
  }
62
74
  });