Small disclaimer - I downgraded to 3.1.3 first to try and jailbreak and was unsuccessful, so I then downgraded to 3.1.2 from 3.1.3 and then did everything listed here. I have been able to downgrade straight to 3.1.2 from 4.0 so I'm just assuming you will be as well. Also, just to cover the bases, if anything should go wrong, simply put the phone into DFU mode, and upgrade back to 4.0. Then follow the instructions from the beginning.