Here is an alternative result.
Theorem. Let $(X,x_0)$ and $(Y,y_0)$ be based spaces. If $(Y,y_0)$ is well-pointed (which means that the inclusion $\{y_0\} \to Y$ is a cofibration), then $\phi$ is an isomorphism.
Proof. The wedge $(A,a_0) \vee (B,b_0)$ has a canonical basepoint. If we take another basepoint $\xi \in (A \sqcup B)/{\sim}$, we get based space denoted by
$$(A,a_0) \vee_\xi (B,b_0) = )(A \sqcup B)/{\sim,\xi)} .$$
Let $(Y',1) = (Y,y_0) \vee_1 (I,0)$, where $1 \in I = [0,1]$. The canonical retraction $r : (Y',1) \to (Y,y_0)$ is a free homotopy equivalence. Since both spaces are well-pointed (note that $(Y',1)$ is always well-pointed, even if $(Y,y_0)$ is not), $r$ is a pointed homotopy equivalence. See [1] Proposition 0.19.
Therefore the map $R = id \vee r: (X,x_0) \vee (Y',1) \to (X,x_0) \vee (Y,y_0)$ is a pointed homotopy equivalence and the diagram
$\require{AMScd}$
\begin{CD}
\pi_1(X) * \pi_1(Y') @>{\phi}>> \pi_1(X \vee Y') \\
@V{id * r_*}VV @VV{R_*}V \\
\pi_1(X) * \pi_1(Y) @>>{\phi}> \pi_1(X \vee Y) \end{CD}
commutes. The vertical arrows are isomorphisms, thus it suffices to show that the upper horizontal arrow is an isomorphism.
Let $u : I \to I, u(t) = 2t$ for $t \le 1/2$, $u(t) = 1$ for $t \ge 1/2$. Define $(X',1/2) = (X,x_0) \vee_{1/2} ([1/2,1],1)$ and $(Y'',1/2) = (Y,y_0) \vee_{1/2} ([0,1/2 ],0)$. We have $(X,x_0) \vee (Y',1) = (X',1/2) \vee (Y'',1/2)$ as unbased spaces. The map $\bar u : (X',1/2) \vee (Y'',1/2) \to (X,x_0) \vee (Y',1)$ obtained by taking the identity on $X$ and $Y$ and $u$ on $I$ is a pointed map and a free homotopy equivalence. Also the restrictions $\bar u_X : (X',1/2) \to (X,x_0)$ and $\bar u_Y : (Y'',1/2) \to (Y',1)$ are pointed maps and free homotopy equivalences. Thus all these maps induce isomorphisms on fundamental groups (see [1] Proposition 1.18). The following diagram commutes:
$\require{AMScd}$
\begin{CD}
\pi_1(X') * \pi_1(Y'') @>{\phi}>> \pi_1(X' \vee Y'') \\
@V{(\bar u_X)_* * (\bar u_Y)_*}VV @VV{\bar u_*}V \\
\pi_1(X) * \pi_1(Y') @>>{\phi}> \pi_1(X \vee Y') \end{CD}
The vertical arrows are isomorphisms and the upper horizontal arrow is an isomorphism by the Proposition in the question.
Corollary. Let $(X,x_0)$ and $(Y,y_0)$ be based spaces. Assume
There exists an open neighborhood $U$ of $y_0$ in $Y$ such that the inclusion $j : (U,y_0) \to (Y,y_0)$ is pointed homotopic to the constant pointed map.
There exists a continuous $\varphi : Y \to I$ such that $ \{y_0\} = \varphi^{-1}(1)$ and $Y \setminus U \subset \varphi^{-1}(0)$.
Then $\phi$ is an isomorphism.
Proof. It is known that 1. + 2. imply that $(Y,y_0)$ is well-pointed. See [3] and [2] Exercise 1.E.6.
Remarks.
-
- is automatically satisfied for metrizable spaces.
-
- is satisfied if there exists an open neighborhood $U$ of $y_0$ in $Y$ such that $(U,y_0)$ is pointed contractible. This condition also occurs in the Proposition of the question.
[1] Hatcher, Allen. Algebraic topology.
[2] Spanier, Edwin H. Algebraic topology. Springer Science & Business Media, 1989.
[3] Strøm, Arne. Note on cofibrations II. Mathematica Scandinavica 22.1 (1968): 130-142.
Best Answer
For any pair of 2-dimensional (connected) CW-complexes $X$ and $Y$, if $\pi_1(X)$ is isomorphic to $\pi_1(Y)$ then there exist maps going each way $X \mapsto Y$ and $Y \mapsto X$ that induce isomorphisms on $\pi_1$. Using what you have already written that the 2-skeleton is $\pi_1$-equivalent to the whole complex, it follows that the only invariant of $\pi_1$-equivalence is the fundamental group itself.
For the proof, first pick $0$-cells $p \in X$ and $q \in Y$ and an isomorphism $\phi : \pi_1(X,p) \to \pi_1(Y,q)$. Now define $f : X \to Y$ as follows. Pick a maximal subtree $T$ in the $1$-skeleton $X^{(1)}$, hence $T$ contains each $0$-cell. Define the restriction $f \mid T$ to be the constant with value $q$.
Next, orient and enumerate the edges $\{e_i\}_{i \in I}$ of $X^{(1)}-T$. Associated to each $e_i$ is an element $[\gamma_i] \in \pi_1(X,p)$ where $\gamma_i = \alpha_i e_i \beta_i$, $\alpha_i$ is the path in $T$ from $p$ to the initial $0$-cell of $e_i$, $\beta_i$ is the path in $T$ from the terminal $0$-cell of $e_i$ to $p$. So far the map is already defined on $\alpha_i$ and on $\beta_i$ to map those paths to the single point $q$, because $f$ is already defined on $T$ so as to take all of $T$ to $q$. Therefore $f$ is already defined on the edge $e_i$ so as to map the endpoints of $e_i$ to the single point $q$. Now extend $f$ over the rest of the edge $e_i$, defining $f \mid e_i$ to be any closed path in $Y$ based at $p$ which represents $\phi[\gamma_i]$.
It follows that, so far, $f$ has been defined on the closed path $\gamma_i = \alpha_i * e_i * \beta_i$ based at $p$ so as to take $[\gamma_i]$ to a closed path $f(\gamma_i)$, based at $q$, representing $\phi[\gamma_i]$.
Finally, for any $2$-cell $d$, its attaching map $\chi_d : S^1 \to X^1$ is homotopic to some path of the form $\gamma_{i_1} \cdots \gamma_{i_K}$, and then since $[\gamma_{i_1} \cdots \gamma_{i_K}]\in \pi_1(X,p)$ is the identity it follows that $\phi[\gamma_{i_1} \cdots \gamma_{i_K}] \in \pi_1(Y,q)$ is the identity and so $f(\gamma_{i_1} \cdots \gamma_{i_K})$ is homotopic to a constant in $Y$. From this it follows that $f \circ \chi_d$ is homotopic to a constant in $Y$. Using this homotopy we can therefore extend $f$ continuously over $d$.