Labelled variables in logic programming: Foundations