  We prove a global implicit function theorem. In particular we show that any
Lipschitz map $f:\bR^n\times \bR^m\to\bR^n$ (with $n$-dim. image) can be
precomposed with a bi-Lipschitz map $\bar{g}:\bR^n\times \bR^m\to \bR^n\times
\bR^m$ such that $f\circ \bar{g}$ will satisfy, when we restrict to a large
portion of the domain $E\subset \bR^n\times \bR^m$, that $f\circ \bar{g}$ is
bi-Lipschitz in the first coordinate, and constant in the second coordinate.
Geometrically speaking, the map $\bar{g}$ distorts $\bR^{n+m}$ in a controlled
manner, so that the fibers of $f$ are straightened out. Furthermore, our
results stay valid when the target space is replaced by {\bf any metric space}.
A main point is that our results are quantitative: the size of the set $E$ on
which behavior is good is a significant part of the discussion. Our estimates
are motivated by examples such as Kaufman's 1979 construction of a $C^1$ map
from $[0,1]^3$ onto $[0,1]^2$ with rank $\leq 1$ everywhere.
  On route we prove an extension theorem which is of independent interest. We
show that for any $D\geq n$, any Lipschitz function $f:[0,1]^n\to \bR^D$ gives
rise to a large (in an appropriate sense) subset $E\subset [0,1]^n$ such that
$f|_E$ is bi-Lipschitz and may be extended to a bi-Lipschitz function defined
on {\bf all} of $\bR^n$. The most interesting case is the case $D=n$. As a
simple corollary, we show that $n$-dimensional Ahlfors-David regular spaces
lying in $\bR^{D}$ having big pieces of bi-Lipschitz images also have big
pieces of big pieces of Lipschitz graphs in $\bR^{D}$. This was previously
known only for $D\geq 2n+1$ by a result of G. David and S. Semmes.
