Restriction of Inverse is Inverse of Restriction

Theorem
Let $S_1$ and $S_2$ be two sets.

Let $f: S_1 \to S_2$ be a bijective mapping.

Let $M_1$ be a subset of $S_1$, i. e. $M_1 \subseteq S_1$.

Let $M_2 = f(M_1)$.

Let $f^{-1}$ be the inverse of $f$.

Let $f \restriction_{M_1 \times M_2}$ be the restriction of $f$ to $M_1 \times M_2$.

Let $f^{-1} \restriction_{M_2 \times M_1}$ be the restriction of $f^{-1}$ to $M_2 \times M_1$.

Then $(f \restriction_{M_1 \times M_2})^{-1}$ exists and is equal to $f^{-1} \restriction_{M_2 \times M_1}$

Proof
Let $x$ be in $M_1$.

Since $f$ is bijective, there exists exactly one $y \in S_2$ such that $f(x) = y$.

Since $f(M_1) = M_2$, $x \in M_2$.

By definition of the restriction, $\forall z \in M_1 : f \restriction_{M_1 \times M_2}(z) = f(z)$.

Therefore there exists exactly one $y \in M_2$ such that $f \restriction_{M_1 \times M_2}(x) = y$.

Since $x \in M_1$ was arbitrary, $f \restriction_{M_1 \times M_2}$ is bijective.

Therefore, $(f \restriction_{M_1 \times M_2})^{-1}$ exists.

Let $y \in M_2$.

Let $x = f^{-1}(y)$.

Since $f$ is bijective, this is equivalent to $f(x) = y$.

Since $\forall z \in M_1 : f \restriction_{M_1 \times M_2}(z) = f(z)$, $f \restriction_{M_1 \times M_2} (x) = f(x)$.

Since $f \restriction_{M_1 \times M_2}$ is bijective, this is equivalent to $(f \restriction_{M_1 \times M_2})^{-1}(y) = x$

Therefore, $f^{-1}(y) = (f \restriction_{M_1 \times M_2})^{-1}(y)$.

By definition of the restriction, $\forall z \in M_2 : f^{-1} \restriction_{M_2 \times M_1}(z) = f^{-1}(z)$.

By transitivity of equality, $(f \restriction_{M_1 \times M_2})^{-1}(y) = f^{-1} \restriction_{M_2 \times M_1}(y)$.

Since $y \in M_2$ was arbitrary, $(f \restriction_{M_1 \times M_2})^{-1} = f^{-1} \restriction_{M_2 \times M_1}$.