occam-verify-cli 1.0.950 → 1.0.955

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 (43) hide show
  1. package/lib/context/aphasic.js +27 -0
  2. package/lib/context/ephemeral.js +28 -0
  3. package/lib/context/liminal.js +2 -2
  4. package/lib/context/synoptic.js +6 -2
  5. package/lib/element/assertion/signature.js +2 -2
  6. package/lib/element/assertion/subproof.js +1 -1
  7. package/lib/element/conclusion.js +2 -2
  8. package/lib/element/deduction.js +2 -2
  9. package/lib/element/label.js +8 -6
  10. package/lib/element/metavariable.js +3 -3
  11. package/lib/element/proofAssertion/step.js +3 -3
  12. package/lib/element/reference.js +7 -5
  13. package/lib/element/signature.js +7 -5
  14. package/lib/element/substitution/frame.js +75 -4
  15. package/lib/element/substitution/reference.js +3 -3
  16. package/lib/element/substitution/statement.js +53 -58
  17. package/lib/element/substitution/term.js +75 -4
  18. package/lib/element/substitution.js +1 -5
  19. package/lib/element/variable.js +2 -2
  20. package/lib/process/unify.js +2 -51
  21. package/lib/utilities/context.js +44 -12
  22. package/package.json +1 -1
  23. package/src/context/aphasic.js +15 -0
  24. package/src/context/ephemeral.js +17 -0
  25. package/src/context/liminal.js +1 -1
  26. package/src/context/synoptic.js +9 -1
  27. package/src/element/assertion/signature.js +1 -1
  28. package/src/element/assertion/subproof.js +1 -1
  29. package/src/element/conclusion.js +2 -2
  30. package/src/element/deduction.js +2 -2
  31. package/src/element/label.js +9 -7
  32. package/src/element/metavariable.js +2 -2
  33. package/src/element/proofAssertion/step.js +3 -2
  34. package/src/element/reference.js +8 -6
  35. package/src/element/signature.js +8 -6
  36. package/src/element/substitution/frame.js +137 -3
  37. package/src/element/substitution/reference.js +3 -3
  38. package/src/element/substitution/statement.js +84 -83
  39. package/src/element/substitution/term.js +137 -4
  40. package/src/element/substitution.js +0 -6
  41. package/src/element/variable.js +1 -1
  42. package/src/process/unify.js +0 -76
  43. package/src/utilities/context.js +61 -18
@@ -3,12 +3,12 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { stripBracketsFromTerm } from "../../utilities/brackets";
7
6
  import { breakPointFromJSON } from "../../utilities/breakPoint";
7
+ import { stripBracketsFromTerm } from "../../utilities/brackets";
8
8
  import { instantiateTermSubstitution } from "../../process/instantiate";
9
9
  import { termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
10
10
  import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
11
- import { ablate, ablates, manifest, attempts, descend, instantiate, unserialises } from "../../utilities/context";
11
+ import { join, ablate, ablates, manifest, attempts, reconcile, sequester, instantiate, unserialises } from "../../utilities/context";
12
12
 
13
13
  export default define(class TermSubstitution extends Substitution {
14
14
  constructor(context, string, node, breakPoint, targetTerm, replacementTerm) {
@@ -139,7 +139,7 @@ export default define(class TermSubstitution extends Substitution {
139
139
 
140
140
  if (targetTermSingular) {
141
141
  manifest((context) => {
142
- descend((context) => {
142
+ sequester((context) => {
143
143
  const targetTerm = this.targetTerm.validate(context, (targetTerm, context) => {
144
144
  const validatesForwards = true;
145
145
 
@@ -174,7 +174,7 @@ export default define(class TermSubstitution extends Substitution {
174
174
 
175
175
  context.trace(`Validating the '${termSubstitutionString}' term substitution's replacement term...`);
176
176
 
177
- descend((context) => {
177
+ sequester((context) => {
178
178
  const replacementTerm = this.replacementTerm.validate(context, (replacementTerm, context) => {
179
179
  const validatesForwards = true;
180
180
 
@@ -195,6 +195,127 @@ export default define(class TermSubstitution extends Substitution {
195
195
  return replacementTermValidates;
196
196
  }
197
197
 
198
+ unifySubstitution(substitution, context) {
199
+ let substitutionUnifies = false;
200
+
201
+ const generalSubstitution = this, ///
202
+ specificSubstitution = substitution,
203
+ generalSubstitutionString = generalSubstitution.getString(),
204
+ specificSubstitutionString = specificSubstitution.getString();
205
+
206
+ context.trace(`Unifying the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution...`);
207
+
208
+ reconcile((context) => {
209
+ const replacementTermUnifies = this.unifyReplacementTerm(substitution, context);
210
+
211
+ if (replacementTermUnifies) {
212
+ const targetTermUnifies = this.unifyTargetTerm(substitution, context);
213
+
214
+ if (targetTermUnifies) {
215
+ context.commit();
216
+
217
+ substitutionUnifies = true;
218
+ }
219
+ }
220
+ }, context);
221
+
222
+ if (substitutionUnifies) {
223
+ context.debug(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
224
+ }
225
+
226
+ return substitutionUnifies;
227
+ }
228
+
229
+ unifyTargetTerm(substitution, context) {
230
+ let targetTermUnifies = false;
231
+
232
+ const generalSubstitution = this, ///
233
+ specificSubstitution = substitution,
234
+ generalSubstitutionString = generalSubstitution.getString(),
235
+ specificSubstitutionString = specificSubstitution.getString();
236
+
237
+ context.trace(`Unifying the '${specificSubstitutionString}' substitution's target term with the '${generalSubstitutionString}' substitution's target term...`);
238
+
239
+ const generalSubstitutionGeneralContext = generalSubstitution.getGeneralContext(),
240
+ specificSubstitutionGeneralContext = specificSubstitution.getGeneralContext(),
241
+ generalSubstitutionTargetTerm = generalSubstitution.getTargetTerm(),
242
+ specificSubstitutionTargetTerm = specificSubstitution.getTargetTerm(),
243
+ generalContext = generalSubstitutionGeneralContext, ///
244
+ specificContext = specificSubstitutionGeneralContext, ///
245
+ generalTerm = generalSubstitutionTargetTerm, ///
246
+ specificTerm = specificSubstitutionTargetTerm; ///
247
+
248
+ join((specificContext) => {
249
+ reconcile((specificContext) => {
250
+ const generalTermNode = generalTerm.getNode(),
251
+ generalVariable = variableFromTermNode(generalTermNode, generalContext);
252
+
253
+ if (generalVariable !== null) {
254
+ const term = specificTerm, ///
255
+ variable = generalVariable, ///
256
+ termUnifies = variable.unifyTerm(term, generalContext, specificContext);
257
+
258
+ if (termUnifies) {
259
+ specificContext.commit(context);
260
+
261
+ targetTermUnifies = true;
262
+ }
263
+ }
264
+ }, specificContext);
265
+ }, specificContext, context);
266
+
267
+ if (targetTermUnifies) {
268
+ context.trace(`...unified the '${specificSubstitutionString}' substitution's target term with the '${generalSubstitutionString}' substitution's target term.`);
269
+ }
270
+
271
+ return targetTermUnifies;
272
+ }
273
+
274
+ unifyReplacementTerm(substitution, context) {
275
+ let replacementTermUnifies = false;
276
+
277
+ const generalSubstitution = this, ///
278
+ specificSubstitution = substitution,
279
+ generalSubstitutionString = generalSubstitution.getString(),
280
+ specificSubstitutionString = specificSubstitution.getString();
281
+
282
+ context.trace(`Unifying the '${specificSubstitutionString}' substitution's replacement term with the '${generalSubstitutionString}' substitution's replacement term...`);
283
+
284
+ const generalSubstitutionSpecificContext = generalSubstitution.getSpecificContext(),
285
+ specificSubstitutionSpecificContext = specificSubstitution.getSpecificContext(),
286
+ generalSubstitutionReplacementTerm = generalSubstitution.getReplacementTerm(),
287
+ specificSubstitutionReplacementTerm = specificSubstitution.getReplacementTerm(),
288
+ generalContext = generalSubstitutionSpecificContext, ///
289
+ specificContext = specificSubstitutionSpecificContext, ///
290
+ generalTerm = generalSubstitutionReplacementTerm, ///
291
+ specificTerm = specificSubstitutionReplacementTerm; ///
292
+
293
+ join((specificContext) => {
294
+ reconcile((specificContext) => {
295
+ const generalTermNode = generalTerm.getNode(),
296
+ generalVariable = variableFromTermNode(generalTermNode, generalContext);
297
+
298
+ if (generalVariable !== null) {
299
+ const term = specificTerm, ///
300
+ variable = generalVariable, ///
301
+ termUnifies = variable.unifyTerm(term, generalContext, specificContext);
302
+
303
+ if (termUnifies) {
304
+ specificContext.commit(context);
305
+
306
+ replacementTermUnifies = true;
307
+ }
308
+ }
309
+ }, specificContext);
310
+ }, specificContext, context);
311
+
312
+ if (replacementTermUnifies) {
313
+ context.trace(`...unified the '${specificSubstitutionString}' substitution's replacement term with the '${generalSubstitutionString}' substitution's replacement term.`);
314
+ }
315
+
316
+ return replacementTermUnifies;
317
+ }
318
+
198
319
  static name = "TermSubstitution";
199
320
 
200
321
  static fromJSON(json, context) {
@@ -268,6 +389,18 @@ export default define(class TermSubstitution extends Substitution {
268
389
  }
269
390
  });
270
391
 
392
+ function variableFromTermNode(termNode, context) {
393
+ let variable = null;
394
+
395
+ const variableNode = termNode.getVariableNode();
396
+
397
+ if (variableNode !== null) {
398
+ variable = context.findVariableByVariableNode(variableNode);
399
+ }
400
+
401
+ return variable;
402
+ }
403
+
271
404
  function targetTermFromTermSubstitutionNode(termSubstitutionNode, context) {
272
405
  const targetTermNode = termSubstitutionNode.getTargetTermNode(),
273
406
  targetTerm = context.findTermByTermNode(targetTermNode);
@@ -224,12 +224,6 @@ export default class Substitution extends Element {
224
224
  return validSubstitution;
225
225
  }
226
226
 
227
- resolve(substitutions, generalContext, specificContext) {
228
- const resolved = true;
229
-
230
- return resolved;
231
- }
232
-
233
227
  commit(generalContext, specificContext) {
234
228
  const contexts = [
235
229
  generalContext,
@@ -8,8 +8,8 @@ import { define } from "../elements";
8
8
  import { instantiate } from "../utilities/context";
9
9
  import { instantiateVariable } from "../process/instantiate";
10
10
  import { provisionallyStringFromProvisional } from "../utilities/string";
11
- import { variableFromTermNode, identifierFromVariableNode } from "../utilities/element";
12
11
  import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
12
+ import { variableFromTermNode, identifierFromVariableNode } from "../utilities/element";
13
13
  import { typeFromJSON, typeToTypeJSON, provisionalFromJSON, provisionalToProvisionalJSON } from "../utilities/json";
14
14
 
15
15
  export default define(class Variable extends Element {
@@ -336,65 +336,6 @@ class MetavariablePass extends ZipPass {
336
336
  ];
337
337
  }
338
338
 
339
- class SubstitutionPass extends ZipPass {
340
- static maps = [
341
- {
342
- generalNodeQuery: frameMetavariableNodeQuery,
343
- specificNodeQuery: frameNodeQuery,
344
- run: (generalFrameMetavariableNode, specificFrameNode, generalContext, specificContext) => {
345
- let success = false;
346
-
347
- const frameNode = specificFrameNode, ///
348
- metavariableNode = generalFrameMetavariableNode; ///
349
-
350
- let context;
351
-
352
- context = generalContext; ///
353
-
354
- const metavariable = context.findMetavariableByMetavariableNode(metavariableNode);
355
-
356
- context = specificContext; ///
357
-
358
- const frame = context.findFrameByFrameNode(frameNode),
359
- frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
360
-
361
- if (frameUnifies) {
362
- success = true;
363
- }
364
-
365
- return success;
366
- }
367
- },
368
- {
369
- generalNodeQuery: termVariableNodeQuery,
370
- specificNodeQuery: termNodeQuery,
371
- run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
372
- let success = false;
373
-
374
- const termNode = specificTermNode, ///
375
- variableNode = generalTermVariableNode; ///
376
-
377
- let context;
378
-
379
- context = generalContext; ///
380
-
381
- const variable = context.findVariableByVariableNode(variableNode);
382
-
383
- context = specificContext; ///
384
-
385
- const term = context.findTermByTermNode(termNode),
386
- termUnifies = variable.unifyTerm(term, generalContext, specificContext);
387
-
388
- if (termUnifies) {
389
- success = true;
390
- }
391
-
392
- return success;
393
- }
394
- }
395
- ];
396
- }
397
-
398
339
  class IntrinsicTermPass extends ZipPassBase {
399
340
  static maps = [
400
341
  {
@@ -463,7 +404,6 @@ const metaLevelPass = new MetaLevelPass(),
463
404
  combinatorPass = new CombinatorPass(),
464
405
  constructorPass = new ConstructorPass(),
465
406
  metavariablePass = new MetavariablePass(),
466
- substitutionPass = new SubstitutionPass(),
467
407
  intrinsicTermPass = new IntrinsicTermPass(),
468
408
  intrinsicMetavariablePass = new IntrinsicMetavariablePass();
469
409
 
@@ -497,22 +437,6 @@ export function unifyMetavariable(generalMetavariable, specificMetavariable, gen
497
437
  return metavariableUnifies;
498
438
  }
499
439
 
500
- export function unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext) {
501
- let substitutionUnifies = false;
502
-
503
- const generalSubstitutionNode = generalSubstitution.getNode(),
504
- specificSubstitutionNode = specificSubstitution.getNode(),
505
- generalNode = generalSubstitutionNode, ///
506
- specificNode = specificSubstitutionNode, ///
507
- success = substitutionPass.run(generalNode, specificNode, generalContext, specificContext);
508
-
509
- if (success) {
510
- substitutionUnifies = true;
511
- }
512
-
513
- return substitutionUnifies;
514
- }
515
-
516
440
  export function unifyTermWithConstructor(term, constructor, generalContext, specificContext) {
517
441
  let termUnifiesWithConstructor = false;
518
442
 
@@ -3,6 +3,7 @@
3
3
  import MenmicContext from "../context/mnemic";
4
4
  import NestedContext from "../context/nested";
5
5
  import TheticContext from "../context/thetic";
6
+ import AphasicContext from "../context/aphasic";
6
7
  import BoundedContext from "../context/bounded";
7
8
  import NominalContext from "../context/nominal";
8
9
  import LiteralContext from "../context/literal";
@@ -10,6 +11,7 @@ import LiminalContext from "../context/liminal";
10
11
  import PhanericContext from "../context/phaneric";
11
12
  import SynopticContext from "../context/synoptic";
12
13
  import IllativeContext from "../context/illative";
14
+ import EphemeralContext from "../context/ephemeral";
13
15
  import BranchingContext from "../context/branching";
14
16
  import NominalFileContext from "../context/file/nominal";
15
17
 
@@ -28,6 +30,14 @@ export function join(innerFunction, ...contexts) {
28
30
  return innerFunction(context);
29
31
  }
30
32
 
33
+ export function posit(innerFunction, context) {
34
+ const ephemeralContext = EphemeralContext.fromNothing(context);
35
+
36
+ context = ephemeralContext; ///
37
+
38
+ return innerFunction(context);
39
+ }
40
+
31
41
  export function ground(innerFunction) {
32
42
  let context;
33
43
 
@@ -46,13 +56,7 @@ export function ablate(innerFunction, context) {
46
56
  const released = context.isReleased();
47
57
 
48
58
  if (!released) {
49
- let contextExtraneousContext = isContextExtraneousContext(context);
50
-
51
- while (contextExtraneousContext) {
52
- context = context.getContext();
53
-
54
- contextExtraneousContext = isContextExtraneousContext(context);
55
- }
59
+ context = ablateContext(context);
56
60
  }
57
61
 
58
62
  return innerFunction(context);
@@ -131,6 +135,14 @@ export function reconcile(innerFunction, context) {
131
135
  return innerFunction(context);
132
136
  }
133
137
 
138
+ export function sequester(innerFunction, context) {
139
+ const aphasicContext = AphasicContext.fromNothing(context);
140
+
141
+ context = aphasicContext; ///
142
+
143
+ return innerFunction(context);
144
+ }
145
+
134
146
  export function serialise(innerFunction, context) {
135
147
  const mnemicContext = context, ///
136
148
  mnemicContextJSON = mnemicContextToMnemicContextJSON(mnemicContext),
@@ -162,13 +174,7 @@ export function ablates(innerFunction, ...contexts) {
162
174
  const released = context.isReleased();
163
175
 
164
176
  if (!released) {
165
- let contextExtraneousContext = isContextExtraneousContext(context);
166
-
167
- while (contextExtraneousContext) {
168
- context = context.getContext();
169
-
170
- contextExtraneousContext = isContextExtraneousContext(context);
171
- }
177
+ context = ablateContext(context);
172
178
  }
173
179
 
174
180
  return context;
@@ -216,10 +222,47 @@ export function evaluate(procedure, terms) {
216
222
  return procedure.call(terms, context);
217
223
  }
218
224
 
225
+ function ablateContext(context) {
226
+ const stated = context.isStated();
227
+
228
+ let contextExtraneousContext = isContextExtraneousContext(context);
229
+
230
+ while (contextExtraneousContext) {
231
+ context = context.getContext();
232
+
233
+ contextExtraneousContext = isContextExtraneousContext(context);
234
+ }
235
+
236
+ const Context = stated ? TheticContext : IllativeContext;
237
+
238
+ context = augmentContext(context, Context);
239
+
240
+ return context;
241
+ }
242
+
243
+ function augmentContext(context, Context) {
244
+ const contextContext = (context instanceof Context);
245
+
246
+ if (!contextContext) {
247
+ context = Context.fromNothing(context);
248
+ }
249
+
250
+ return context;
251
+ }
252
+
219
253
  function isContextExtraneousContext(context) {
220
- const contextBoundedContext = (context instanceof BoundedContext),
221
- contextNominalFileContext = (context instanceof NominalFileContext),
222
- contextExtraneousContext = (!contextBoundedContext && !contextNominalFileContext);
254
+ const contextSubstantiveContext = isContextSubstantiveContext(context),
255
+ contextExtraneousContext = !contextSubstantiveContext;
223
256
 
224
257
  return contextExtraneousContext;
225
- }
258
+ }
259
+
260
+ function isContextSubstantiveContext(context) {
261
+ const contextTheticContext = (context instanceof TheticContext),
262
+ contextIllativeContext = (context instanceof IllativeContext),
263
+ contextBoundedContext = (context instanceof BoundedContext),
264
+ contextNominalFileContext = (context instanceof NominalFileContext),
265
+ contextSubstantiveContext = (contextTheticContext || contextIllativeContext || contextBoundedContext || contextNominalFileContext);
266
+
267
+ return contextSubstantiveContext;
268
+ }