The dreadful algebra of necessity
The difference between the dreadful algebra of necessity and the ordinary kind handed down from ancient Klatchian mathematicians has to do with the handling of the unknown variable. The chalkboard variety has found techniques to describe it in terms of the known; the practical, life-and-death version involves determining the outcome of the combination of two knowns (both dreadful) and proving it (or not) by experiment. The unknown variable is usually Life V Death.
In Snuff, Havelock Vetinari reads the description of the phenomenon by The Quite Reverend Mightily-Praiseworthy-Are-Ye-Who-Exalteth-Om Oats1 in relation to Goblins, who may face it more often than more fortunate races, but it is not unique to them. Humans have met the hideous prospect throughout history, in snowbound mountain passes, on lifeboats drifting in unknown seas, in war and famine. The question is always: what atrocity may be committed on an individual or small group to allow the survival of the larger group, tribe or race?
The concept has been mentioned in previous books. In Carpe Jugulum, the Edge-Witch's decision is to allow the baby to die so that the mother may have another opportunity to advance the race. Monstrous Regiment mentions an exigency in the Ibblestarn campaign requiring starving soldiers to eat each others' legs (not quite cannabalism, they argued: that would mean the whole soldier).
Goblins, as the most under-privileged and despised race on the Discworld, encounter the dreadful dilemma so often that they have special traditions and protocols around it, like the special Unggue pot called the soul of tears, "the most beautiful of all the pots, carved with little flowers and washed with tears". One of these would commemorate a Goblin mother's having to eat her baby to survive. To hang, or "survive" is the prime directive of the Goblins, and the most they can hope for.
(1) Fortunately, he has not objected to the contraction "Mightily", or the title "Pastor Oats". Constable Visit-the-Infidel-With-Explanatory-Pamphlets might take note.