What does "suffering" mean? Define your boolean function, apply it to the state of the program, and you'll know if the program is currently suffering.