[step:Transport the variable rule through the exchanged context]
Consider a variable judgment occurring in the original derivation. Its context has the form
\begin{align*}
C(\Delta_0),\Theta=\Gamma,x:A,y:B,\Delta_0,\Theta,
\end{align*}
where $\Delta_0$ is an initial segment of $\Delta$ and $\Theta$ is a finite auxiliary local context introduced inside the rule instance. Let the variable in the conclusion be denoted by $z$. The side condition in the transport invariant gives the well-formed exchanged context
\begin{align*}
C^\sigma(\Delta_0),\Theta^\sigma\ \mathsf{ctx}.
\end{align*}
Hence every final extension used below is a well-formed dependent context extension of the prefix from which the variable judgment is first derived.
If $z$ is declared in $\Gamma$, then its type is unchanged by the exchange. Since $\Gamma$ is an initial segment of both $C(\Delta_0),\Theta$ and $C^\sigma(\Delta_0),\Theta^\sigma$, the ordinary variable rule gives the same variable judgment in $\Gamma$. The [Weakening Rule](/theorems/9622) [citetheorem:9622] transports it through the well-formed extension from $\Gamma$ to $C^\sigma(\Delta_0),\Theta^\sigma$.
If $z=x$, then $x:A$ is a declaration in the swapped context prefix
\begin{align*}
\Gamma,y:B,x:A.
\end{align*}
The type $A$ is still well formed at that point because $\Gamma \vdash A\ \mathsf{type}$ is derivable and $A$ has no dependence on $y$. The variable rule gives $\Gamma,y:B,x:A \vdash x:A$, and the Weakening Rule [citetheorem:9622] transports this judgment through the well-formed extension by $\Delta_0^\sigma,\Theta^\sigma$. Hence
\begin{align*}
C^\sigma(\Delta_0),\Theta^\sigma \vdash x:A.
\end{align*}
If $z=y$, then $y:B$ is a declaration in the swapped context prefix
\begin{align*}
\Gamma,y:B.
\end{align*}
The type $B$ is well formed at that point because $\Gamma \vdash B\ \mathsf{type}$ is derivable. The variable rule gives $\Gamma,y:B \vdash y:B$, and the Weakening Rule [citetheorem:9622] transports this judgment through the well-formed extension by $x:A,\Delta_0^\sigma,\Theta^\sigma$. Hence
\begin{align*}
C^\sigma(\Delta_0),\Theta^\sigma \vdash y:B.
\end{align*}
Suppose $z$ is declared in $\Delta_0$. Write the relevant part of $\Delta_0$ as
\begin{align*}
\Delta_0=\Delta_1,z:C,\Delta_2.
\end{align*}
By definition of the swapped tail,
\begin{align*}
\Delta_0^\sigma=\Delta_1^\sigma,z:C^\sigma,\Delta_2^\sigma.
\end{align*}
Thus $z:C^\sigma$ is a declaration in the prefix $\Gamma,y:B,x:A,\Delta_1^\sigma,z:C^\sigma$. The variable rule gives the judgment for $z$ in that prefix, and the Weakening Rule [citetheorem:9622] transports it through the remaining well-formed extension $\Delta_2^\sigma,\Theta^\sigma$. Therefore
\begin{align*}
C^\sigma(\Delta_0),\Theta^\sigma \vdash z:C^\sigma.
\end{align*}
Finally suppose $z$ is declared in the auxiliary local context $\Theta$. Write the relevant part of $\Theta$ as
\begin{align*}
\Theta=\Theta_1,z:C,\Theta_2.
\end{align*}
By the recursive definition of local-context reindexing,
\begin{align*}
\Theta^\sigma=\Theta_1^\sigma,z:C^\sigma,\Theta_2^\sigma.
\end{align*}
Thus $z:C^\sigma$ is a declaration in the prefix $C^\sigma(\Delta_0),\Theta_1^\sigma,z:C^\sigma$. The variable rule gives the judgment for $z$ in that prefix, and the Weakening Rule [citetheorem:9622] transports it through the remaining well-formed extension $\Theta_2^\sigma$. Therefore
\begin{align*}
C^\sigma(\Delta_0),\Theta^\sigma \vdash z:C^\sigma.
\end{align*}
In each case, the displayed judgment is exactly the reindexing of the original variable judgment for $z$.
[/step]