Categories and the Rezk completion formalized in HoTT