I think there is a legitimate out for the utilitarian logician here, based on the fact that this scenario will never obtain in reality. In the ivory tower, the utilitarian says that "It is better for five people to die than more than five" and this is logically equivalent to saying "In thought experiments, it is better to take an action which leads to five deaths than more than five deaths, ceteris paribus." In the real world, we do not enjoy this kind of mathematical certainty. What if pulling the lever derails the train and hundreds are killed? What if the tunnel with forty workers collapses as the train kills the five in the other tunnel? NotPhil makes this point, though I wonder if he will keep to the non-interventionist high road if there are no workers on the alternate track, and therefore a chance of saving everyone. In the real world, uncertainty and values apply. Greg may or may not be willing to interfere with fate if there's a good chance it will save forty and put five at risk. He may also consider whether he knows and cares about any of the potential victims. This also helps with the horrifying scenario of chopping up one healthy person to get organs which will save a number of sick people. Killing someone for their organs is exceedingly objectionable, and certainly not worth it to have a chance of saving two or three others, assuming the transplants go well. But if a pandemic threatens with high probability to destroy the human race, and a misanthropic scientist is threatening to destroy the effective antidote he invented, it may be justified to call the snipers in.
Well, the point of thought experiments like this is that they're freed from the many problems of reality. They isolate the key variables so that we can see how they alone make a difference to our understanding of the world. If your answer to the tidy landscape of thought experiments different to a real world counterpart, it can give you a deeper understanding of why and how you're accessing things.
Agreed that thought experiments are valuable tools that enable us to analyze principles without the distracting details of the real world. We can ignore questions about the relative worth of human lives, probabilities, and individual preferences. Therefore I conclude that, in the thought experiment, it is better to divert the train because forty is greater than five, and my reservations about altering the course of events I am not responsible for are not as important as keeping as many people alive as possible. The conclusions we draw in the thought experiment apply to the real world to the extent that there are no specific, relevant circumstances that contradict the simplifying assumptions we made in the thought experiment. If we find out that the forty workers are in fact automatons, or they are men who have committed capital offenses, or they are comatose centenarians, or they are fertilized eggs, we may reconsider our conclusions. I maintain that there is a specific, relevant circumstance that applies to every real-world scenario to which this thought experiment might be illuminating. In posing the problem, you guarantee that "The death toll is bound to be smaller" if Greg diverts the train. This is a certainty that we will never have in the real world, and this ambiguity will inevitably affect the way we think about the decision.