* Normalize a predicate argument that may be a string. * * `assume()` and `verify()` accept a predicate as a `BoxedExpression`, a * MathJSON expression, or a **string**. A string is parsed as LaTeX: * * - `$…$` / `$$…$$`-delimited: the delimiters are stripped, then parsed * (`asLatexString`)
( ce: IComputeEngine, predicate: Expression | string, who: 'assume' | 'verify' )
| 44 | * A **non-string** input is boxed raw, exactly preserving the previous |
| 45 | * behavior (an already-canonical `Expression` stays canonical). |
| 46 | * |
| 47 | * A **string** is boxed CANONICALLY for `verify()`: a freshly parsed |
| 48 | * relational such as `Less(x, 0)` only reduces against the assumptions DB |
| 49 | * (`x < 0 → False` under `assume(x > 0)`) once its operator definition is |
| 50 | * bound, i.e. in canonical form — a raw parse would evaluate back to itself |
| 51 | * and `verify()` would return `undefined` where the boxed-expression path |
| 52 | * returns `false`. |
| 53 | * |
| 54 | * For `assume()` a string is boxed RAW instead, and `assume()` canonicalizes |
| 55 | * it itself, so that the whole predicate is canonicalized in one place — |
| 56 | * canonicalization binds every free symbol the predicate mentions, and |
| 57 | * `assume()` must be the call that does it for the names it is answerable |
| 58 | * for. The ownership snapshot the rollback needs is therefore taken here, |
| 59 | * before the string is parsed or boxed (`introducibleNames`). |
| 60 | */ |
| 61 | function predicateFromArg( |
| 62 | ce: IComputeEngine, |
| 63 | predicate: Expression | string, |
| 64 | who: 'assume' | 'verify' |
| 65 | ): { predicate: Expression; undeclared: string[] } { |
| 66 | // The ownership snapshot: the names the scope already binds, read BEFORE |
| 67 | // this call parses or boxes anything, so a binding the call itself causes |
no test coverage detected