Summary: Problem: To solve `Tuple[int, str, bool, bool] <: Tuple[int, *Ts, int]`, we need to solve `[int, str, bool, bool] <: [int, *Ts, int]`. We do that by removing matching elements of known length from both the prefix and the suffix. In the above example, `int` is in both prefixes, so we extract it. Next, the left side has `str`, which has a known fixed length 1, but the right side has `*Ts`, which doesn't have a known length. So, we don't extract that. Likewise, we can extract the matching suffix of `[bool] vs [int]` since they have known lengths. (We just split by lengths here, without checking for compatibility. That happens in `solve`.) So, after splitting, we get ``` [int] - [str, bool] - [bool] [int] - [ *Ts ] - [int] ``` We solve each part pairwise. We check `int <: int`, `[str, bool] <: [*Ts]`, and `bool <: int`. So, we end up solving it as `Ts = Tuple[str, bool]`. There are other cases like unbounded tuples, bound vs free variables, multiple `*Ts`, and so on, but this is the core idea. This is what TypeScript [does](microsoft/TypeScript#39094) for its variadic tuples. Note that we don't yet support unpacking unbounded tuples or concatenation of multiple variadics (that's in a future PEP). Reviewed By: grievejia Differential Revision: D26520882 fbshipit-source-id: 0df0d74becf3ee2a85caf3819093ccc336a5029d