TLDR:
Pin compatible - Yes
Binary code compatible - No, for anything much more complex than 'blink a LED', even if you patch the CONFIG, due to the many SFR and hardware peripheral module differences.
OTOH if you've got full sourcecode + the corrct compiler to rebuild it, you are in with a chance of porting it sucessfully if you carefully work through the code, referring to the migration document 1GHz linked, and the two device datasheets, and all the PIC 18F4580 errata, adapting the code as required.