(indexingSet: Expression)
| 134 | * |
| 135 | * A component that is not provably numeric at all — a matrix ROW, a string, an |
| 136 | * `unknown`-typed element — keeps `number` too, ahead of both: those have no |
| 137 | * norm for this claim to be about. |
| 138 | * |
| 139 | * `real` is the claim for every other component set, complex components |
| 140 | * included. No narrower tier is: unlike `|·|` of a scalar, a norm does not |
| 141 | * preserve the integer or rational tier — `‖(1, 1)‖ = √2`. |
| 142 | */ |
| 143 | export function euclideanNormType( |
| 144 | components: ReadonlyArray<OperandDescriptor> |
| 145 | ): string { |
| 146 | if (components.length === 0) return 'number'; |
| 147 | if (!components.every((c) => isSubtype(c.type, 'number'))) return 'number'; |
| 148 | if ( |
| 149 | components.every( |
| 150 | (c) => c.facts.finite === true || isSubtype(c.type, 'complex') |
| 151 | ) |
| 152 | ) |
| 153 | return 'real'; |
| 154 | if (components.every((c) => isSubtype(c.type, EXTENDED_REAL_TYPE))) |
| 155 | return 'real | +oo'; |
| 156 | return 'number'; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Result type of the Euclidean norm of a fixed-arity point (`Tuple` operand of |
| 161 | * `Norm`/`Abs`): the scalar norm type, unless the point broadcasts. Only a |
| 162 | * point whose components the structural view exposes carries the scalar |
| 163 | * claim; a point-TYPED symbol keeps the wide `number`. |
| 164 | */ |
| 165 | export function pointNormType(d: OperandDescriptor): string { |
| 166 | if (pointNormBroadcasts(d)) return 'list<number>'; |
| 167 | const children = operandChildren(d); |
| 168 | if (children === undefined) return 'number'; |
| 169 | return euclideanNormType(children); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * EL-4: Convert known infinite integer sets to their equivalent Limits bounds. |
| 174 | * Returns undefined if the set cannot be converted to a Limits form. |
| 175 | * |
| 176 | * Mappings: |
| 177 | * - NonNegativeIntegers (ℕ₀) → [0, ∞) |
| 178 | * - PositiveIntegers (ℤ⁺) → [1, ∞) |
| 179 | * - NegativeIntegers (ℤ⁻) → Not supported (would need negative direction) |
| 180 | * - Integers (ℤ) → Not supported (bidirectional) |
| 181 | * - Other sets (Reals, Complexes, etc.) → Not supported (non-integer) |
| 182 | */ |
| 183 | export function convertInfiniteSetToLimits( |
| 184 | domainSymbol: string |
| 185 | ): { lower: number; upper: number; isFinite: false } | undefined { |
| 186 | switch (domainSymbol) { |
| 187 | case 'NonNegativeIntegers': |
| 188 | // ℕ₀ = {0, 1, 2, 3, ...} |
| 189 | return { lower: 0, upper: MAX_ITERATION, isFinite: false }; |
| 190 | case 'PositiveIntegers': |
no test coverage detected