Dynamics AX 4.0 is a very old system, so there is a good chance your business may have fundamentally changed where reimplementing makes the most sense.
A very interesting option for Dynamics AX 4.0 users is upgrading to AX 2009, then migrating data to Dynamics 365 for Finance and Operations, Enterprise Edition. The effort to get to AX 2009 from 4.0 could be low enough that it will still produce savings on a data upgrade. The goal would be purely to use the AX 2009 migration toolset, so upgrade corners could safely be cut, such as skipping form and report upgrade efforts and focusing on schema objects.
If you need your code and data in their entirety, you could double upgrade. First to AX 2012 R3, then to Dynamics 365 for Finance and Operations, Enterprise Edition. This could give you a potentially more complete set of code and data. This could be considered higher risk though, coming from a very old system and running data through two sets of upgrade scripts.
Learn about the planned Microsoft Dynamics 365 for Finance and Operation feature releases from October 2019 through March 2020 and get a complimentary light Cloud Assessment ($5000)