On specifying a problem
Before analysing an algorithm we have to fix what counts as a valid input, what the output should be, and precisely when an output is correct. Until then, “find the shortest path” is a wish, not a problem.
The correctness relation
Let be the set of inputs and the set of outputs. A computational problem is a relation : the pair belongs to exactly when is an acceptable answer for . Stating it as a relation keeps the door open for inputs that admit several correct answers.
An algorithm solves the problem when, for every , it halts and holds. Termination and correctness are separate obligations — neither implies the other.