My understanding (IANAL) so far was that licenses apply to the code and binaries derived from the code. Why do you think that GPL also applies to a from-scratch rewrite? There are cases where a rewrite was done precisely to circumvent license restrictions.
This is a question of Copyright law [1], which also differs depending the jurisdiction. > from-scratch rewrite
rewriting is literally a derivative work. With 'from-scratch' you probably mean some form of 'clean-room implementation', which is specifically required to circumvent copyright protection. Performing such an implementation is quite laborious and needs to be properly documented. That an opensource project with more than 400 contributors can reasonably attest this is somewhat questionable.
Clean-room implementations are not required to avoid infringing when you make your own version of something else. They just make it easier to successfully defend if you are sued for infringement.
If your code does not copy any copyrightable expression from mine it is not a derivative work, so if I sue you (legitimately, not because I just hope a lawsuit will intimidate you into agreeing to my demands) it means I've found things in your work that I think are copies of copyrightable things from my work.
If you haven't done a clean-room implementation your defense is probably going to rely on finding those things in other works besides mine and using one or more of these arguments: (1) these things are widely used and known and your copied yours from somewhere other than my work, (2) the ones in my work are just copies from those other works so I don't have any copyright on them for you to infringe, and (3) there are so few reasonably ways to do these things that everyone who writes them comes up with nearly identical solutions and that's why yours are similar to mine.
If you have done a clean-room implementation and kept good records to prove that, your defense is that you never saw any of my copyrightable expression so cannot possibly have copied.