Patience: proved well-formedness of stacks and termination