I apologize if the title of this question can be better formulated, but I recently encountered a situation where what I thought was valid substitution led to an incorrect thing—at least I think.
I was trying to show myself why double negation elimination is not a theorem but how triple negation and single negation are equivalent. The former, $\neg\neg C \rightarrow C$, can be symbolized as
$((C \rightarrow \bot) \rightarrow \bot) \rightarrow C \tag{1}.$
which is just a special case of
$((C \rightarrow B) \rightarrow B) \rightarrow C \tag{2}.$
The latter, $\neg\neg\neg A \leftrightarrow \neg A$, can be symbolized as
$(((A \rightarrow \bot) \rightarrow \bot) \rightarrow \bot) \leftrightarrow (A \rightarrow \bot) \tag{3}.$
which is a special case of
$(((A \rightarrow B) \rightarrow B) \rightarrow B) \leftrightarrow (A \rightarrow B) \tag{4}.$
I thought it was valid to substitute $C$ for $(A \rightarrow B)$ in $(4)$ which would then reduce $(4)$ to
$((C \rightarrow B) \rightarrow B) \leftrightarrow C \tag{5}.$
Obviously assuming $(2)$ isn't a theorem means that $(5)$ can't be proven thereby contradicting the fact that triple negation is equivalent to single negation.
Does this mean that one can never substitute "across" connectives?
Edit
It's important to state that the reason I settled to prove the general forms (which is obviously much stronger than special cases) is due to an answer by Rob Arthan where it seems to me that he has a proof of $(4)$.