Text this: Theoretical foundations of the organization of branches and repetitions in programs in the logic programming language Prolog