3 ms·
> C is a union of A and B, aka a "sum type", so its cardinality is the sum of cardinalities of A and B That's exactly what's wrong. The cardinality is len(A ∪
by marcosdumay 2y ago
> C is a union of A and B, aka a "sum type", so its cardinality is the sum of cardinalities of A and B
That's exactly what's wrong. The cardinality is len(A ∪ B) = len(A) + len(B) - len(A ∩ B).
Also, the Cartesian product is a tagged operation. It literally creates a result where you access the elements by index.
- nine_k 2y agoWe reasonably assume that A ∩ B = ∅ in all practical cases, such as `int | None` or `string | number `, etc. Yes, a Cartesian product is tagged (each axis is), but it does not affect the fact that len(A * B) = len(A) * len(B), hence it's logical to use multiplication to denote "record types".
- marcosdumay 2y agoThat's not a good assumption, and even the original example is Bool + Bool; len(Bool ∪ Bool) = 2 * len(Bool) is trivially false. About the Cartesian product, the tags create that rule. Untagged multiplication again has fewer elements.