Stav dette: The hidden mathematical logic of stories