An analytical method to recover the history of the IMF from the metallicity distribution of the G-dwarfs of the solar neighbourhood