Juan Martin Del Potro booked his place in the semi-finals of the ATP World Tour Finals after a superb win over Roger Federer.