The function collapsing weakly Mahlo cardinals