# In any commutative diagram with isomorphism $f$ we may replace $f$ by $f^{-1}$?

Let $D$ be a diagram in category $\mathcal{C}$ that involves the isomorphism $f$. I don't know how to express that in formal terms.

Under what conditions can we replace $f$ in the diagram by $f^{-1}$ and preserve commutativity?

I want to say whenever the only other arrows in the diagram are independent of $f$ or are of the form $f \circ g_1 \circ \dots$ but I'm not satisfied with this meager level of formality.

Have any better idea?

A commutative diagram is just a system of equations. You can replace a particular occurrence of $f$ with $f^{-1}$ (going the other direction) if $f$ is not part of what I'll call an "opposing square" (see case two below) and every equation induced by a path going through this particular occurrence of $f$ is of the form $h_i = f \circ g_i$ or they are all of the form $h_i = g_i \circ f$, (where we can treat $h_i = f$ as $h_i = id \circ f$ or $h_i = f \circ id$ as desired for this purpose) i.e. every path through this occurrence of $f$ in the diagram either (consistently) begins or ends with this occurrence of $f$. This corresponds to $h_i = f \circ g_i \implies f^{-1}\circ h_i = g_i$ or $h_i = g_i \circ f \implies h_i \circ f^{-1} = g_i$.
There are three remaining cases. First, we could have a path of the form $k = g \circ f \circ h$, i.e. $$\require{AMScd} \begin{CD} B @>f>> C \\ @AhAA @VVgV \\ A @>>k> D \end{CD}$$ becomes $$\begin{CD} B @<f^{-1}<< C \\ @AhAA @VVgV \\ A @>>k> D \end{CD}$$ which corresponds to no equation and thus could be said to vacuously commute. In this sense, you could allow or disallow it. The point is that it is implied by the first diagram (trivially), but not equivalent to the first diagram. As the second case, we could go from the bottom diagram above to the top, which would go from a pair of paths that don't give rise to equation to a pair of paths that have no a priori reason to commute. If this case happens, then you can go from a diagram that commutes to a diagram that doesn't commute. I'll call this situation an opposing square.
The final case is when this occurrence of $f$ is simultaneously the first arrow in one path and the last arrow in another where both paths start and finish at the same (occurrence of) an object in the commutative diagram. That is, we have $f \circ h = g \circ f$. It takes a bit of thought, but the only way this can happen with both $f$s being the same occurrence of $f$ in the diagram is if both $h$ and $g$ are loops corresponding to the equations $h = id$ and $g = id$. In this case, replacing this occurrence $f$ with $f^{-1}$ pointing the other direction preserves (and reflects) commutativity. The condition I gave in my first paragraph unnecessarily excludes this case, though it is unusual to have such loops in a commutative diagram.
So, if an occurrence $f$ is not a part of any opposing square and that occurrence $f$ is also not in the middle of any path in a commuting pair of paths, then it can be flipped and replaced with $f^{-1}$ producing an equivalent commutative diagram. (Note, this is not an "if and only if". It's completely possible that inverting an $f$ will be meaning preserving even if the above conditions don't hold.)