Adapted a helper function for debugging types from the Flyspeck project wiki to NHol.