MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / evaluateExistsUnique

Function evaluateExistsUnique

src/compute-engine/library/logic.ts:421–457  ·  view source on GitHub ↗

* Evaluate ExistsUnique over a finite domain. * ∃!x∈S. P(x) is true iff exactly one x in S satisfies P(x).

(
  args: ReadonlyArray<Expression>,
  { engine: ce }: { engine: ComputeEngine }
)

Source from the content-addressed store, hash-verified

419 else if (isUnresolvedCollectionOperand(x)) score -= 1;
420 }
421 return score;
422 };
423 if (
424 values.some((x) => isFiniteBroadcastParticipant(x)) &&
425 listReadiness(values) > listReadiness(ops)
426 ) {
427 // On the asynchronous path this runs after an `await`, so the
428 // evaluation must be given the registry and the context stack of its
429 // evaluation explicitly: the engine does not keep them installed.
430 const rebuild = () => ce.function(name, values).evaluate(evalOptions);
431 return evalOptions._effects === undefined
432 ? rebuild()
433 : runWithEvaluationEffects(
434 ce,
435 evalOptions._effects,
436 rebuild,
437 evalOptions._contextStack,
438 evalOptions._precisionWindow
439 );
440 }
441 return reduce(values, { engine: ce });
442}
443
444/** The boolean VALUE an operand's type proves: `true`/`false` for a value
445 * type, `undefined` otherwise (boolean value types,
446 * `docs/plans/2026-08-29-boolean-value-types.md` §3.1). */
447function booleanClaim(x: OperandDescriptor): boolean | undefined {
448 const t = x.type;
449 return typeof t === 'object' &&
450 t.kind === 'value' &&
451 typeof t.value === 'boolean'
452 ? t.value
453 : undefined;
454}
455
456/** Result type of a connective from its operands' claims by the truth
457 * table: `And` is `false` as soon as one operand is, `true` when all are;
458 * `Or` the dual; `Not` flips; `Xor` folds when every operand is decided.
459 * Anything undecided keeps `boolean`. An operand whose type is not a plain
460 * `boolean` (it may be absent, or a collection) keeps the head's declared

Callers

nothing calls this directly

Calls 4

symFunction · 0.90
subsMethod · 0.65
evaluateMethod · 0.65

Tested by

no test coverage detected