Solving Internal Habit Formation Models Through Dynamic Programming in Infinite Dimension