Labelled Variables in Logic Programming: Foundations