For example, instead of: append(B1, B2, B12), append(B3, B4, B34), append(B12, B34, B1234), append(B1234, B5, B12345), append(B12345, [0], B), you can use `phrase/2` from `library(dcgs)` to write this as: phrase((B1,B2,B3,B4,B5,[0]), Bs) yielding the list `Bs`.