The Collatz (or 3m+1) problem is examined in terms of a free semigroup on which suitable diophantine and rational functions are defined. The elements of the semigroup, called T-words, comprise the information about the Collatz operations which relate an odd start number to an odd end number, the group operation being the concatenation of T-words. This view puts the concept of encoding vectors, first introduced in 1976 by Terras, in the proper mathematical context. A method is described which allows to determine a one-parameter family of start numbers compatible with any given T-word. The result brings to light an intimate relationship between the Collatz 3m+1 problem and the 3m-1 problem. Also, criteria for the rise or fall of a Collatz sequence are derived and the important notion of anomalous T-words is established. Furthermore, the concept of T-words is used to elucidate the question what kind of cycles—trivial, nontrivial, rational—can be found in the Collatz 3m+1 problem and also in the 3m-1 problem. Furthermore, the notion of the length of a Collatz sequence is discussed and applied to average sequences. Finally, a number of conjectures are proposed.