* Evaluate Exists over a finite domain. * ∃x∈S. P(x) is true iff P(x) is true for at least one x in S. * * Symbolic simplifications: * - ∃x. True → True * - ∃x. False → False * - ∃x. P (where P doesn't contain x) → P * * Nested quantifiers: * - ∃x∈S. ∃y∈T. P(x,y) evaluates over the Cartesia
(
args: ReadonlyArray<Expression>,
{ engine: ce }: { engine: ComputeEngine }
)
| 353 | * the host capability registry an asynchronous evaluation carries in |
| 354 | * `_effects`) minus the handler-only fields (`engine`, `expression`). */ |
| 355 | function evaluateOptionsOf( |
| 356 | options: EvaluateHandlerOptions |
| 357 | ): Partial<EvaluateOptions> { |
| 358 | const { |
| 359 | numericApproximation, |
| 360 | materialization, |
| 361 | signal, |
| 362 | _effects, |
| 363 | _contextStack, |
| 364 | _precisionWindow, |
| 365 | } = options; |
| 366 | return { |
| 367 | numericApproximation, |
| 368 | materialization, |
| 369 | signal, |
| 370 | _effects, |
| 371 | _contextStack, |
| 372 | _precisionWindow, |
| 373 | }; |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Shared tail of the sync/async short-circuit handlers, once every surviving |
| 378 | * operand has been evaluated into `values` (on the scalar path, a decider has |
| 379 | * already returned early, and a failed operand has already been returned when |
| 380 | * no operand decided). A collection produced by evaluation is |
| 381 | * handed back to the driver's broadcast by rebuilding the call over the |
| 382 | * values (see the element-wise paragraph of `evaluateShortCircuit`); anything |
| 383 | * else goes to the symbolic reducer. |
| 384 | */ |
| 385 | function finishShortCircuit( |
| 386 | ce: ComputeEngine, |
| 387 | name: ShortCircuitOperator, |
| 388 | ops: ReadonlyArray<Expression>, |
| 389 | values: ReadonlyArray<Expression>, |
| 390 | decide: Decider, |
| 391 | reduce: Reducer, |
| 392 | evalOptions: Partial<EvaluateOptions> |
| 393 | ): Expression | undefined { |
| 394 | // On the element-wise path, an operand that evaluates to an error VALUE |
| 395 | // (an `Error` node, not a list with error cells) is the answer, unless an |
| 396 | // operand decides the result by itself (`And(False, e)` is `False`, as |
| 397 | // the symbolic reducer absorbs it). Broadcast, the one error was copied |
| 398 | // into every cell: `Or(Sin(P) < [1, 2], Sin(P) > 0)` with `P = [5, 6, 7]` |
| 399 | // was a list of three `incompatible-dimensions` errors. |
| 400 | const error = values.find((v) => v.operator === 'Error'); |
| 401 | if (error && !values.some((v, i) => decide(ce, v, i) !== undefined)) |
| 402 | return error; |
| 403 | // The driver maps a call when an operand is a list value and no operand is |
| 404 | // a list by type that has no value yet. It did not map this call (the |
| 405 | // handler would not run otherwise). Evaluation brings the call nearer to |
| 406 | // that state in two ways: an operand becomes a list value (`u > 0`), or an |
| 407 | // operand that held the driver back becomes a scalar (a read out of range |
| 408 | // that gives `Missing`). `listReadiness` counts both, and the call is |
| 409 | // rebuilt only when the values score higher than the operands did: |
| 410 | // `And(c, L)`, with `c` a list and `L` a list symbol that has no value, is |
| 411 | // not rebuilt and stays symbolic. The operands of the rebuilt call are |
| 412 | // the values, and evaluating a value again gives the same value, so the |
no test coverage detected