An Automated Approach to the Collatz Conjecture

We explore the Collatz conjecture and its variants through the lens of termination of string rewriting. We construct a rewriting system that simulates the iterated application of the Collatz function on strings corresponding to mixed binary–ternary representations of positive integers. We prove that the termination of this rewriting system is equivalent to the Collatz conjecture. We also prove that a previously studied rewriting system that simulates the Collatz function using unary representations does not admit termination proofs via natural matrix interpretations, even when used in conjunction with dependency pairs. To show the feasibility of our approach in proving mathematically interesting statements, we implement a minimal termination prover that uses natural/arctic matrix interpretations and we find automated proofs of nontrivial weakenings of the Collatz conjecture. Although we do not succeed in proving the Collatz conjecture, we believe that the ideas here represent an interesting new approach.


Introduction
Let N = {0, 1, 2, . . .} denote the natural numbers and N + = {1, 2, 3, . . .} denote the positive integers.We define the Collatz function C : N + → N + as Given a function f and a number k ∈ N, the function f k denotes the kth iterate of f , defined as . The well-known Collatz conjecture is the following: Conjecture 1.1.For all n ∈ N + , there exists some k ∈ N such that This is a longstanding open problem and there is a vast literature dedicated to its study.For its history and comprehensive surveys on the problem, we refer the reader to Lagarias [Lag10,Lag11,Lag12].See also the work by Tao [Tao20] for dramatic recent progress on the problem.Definition 1.2 (Convergent function).Consider a function f : X → X and a designated element z ∈ X.Given x ∈ X, the sequence of iterates f N (x) := (x, f (x), f2 (x), . . . ) is called the f -trajectory of x.If the trajectory f N (x) reaches a cycle containing z, the trajectory is convergent to z for x.If for all x ∈ X the trajectory f N (x) is convergent to z, the function f is convergent to z. 1As of 2020, it has been checked by computation that for all n ≤ 2 68 the Collatz trajectory of n is convergent [Bar21]. 2 This fact, along with the heuristic argument that on average the iterates in a trajectory tend to decrease [Lag85], is often used as evidence to support the belief that the conjecture is true.On a different note, Conway proved that a generalization of the problem is undecidable [Con72], which Kurtz and Simon later extended to a variant even closer to the Collatz conjecture [KS07].While the prevailing opinion is that the Collatz conjecture holds, and the heuristic arguments suggest that an average trajectory is convergent, the undecidability results help explain why this seems to be so hard to show.
In this paper, we describe an approach based on termination of string rewriting to automatically search for a proof of the Collatz conjecture.Although trying to prove the Collatz conjecture via automated deduction is clearly a moonshot goal, there are two recent technological advances that provide reasons for optimism that at least some interesting variants of the problem might be solvable.First, the invention of the method of matrix interpretations [HW06,EWZ08] and its variants such as arctic interpretations [KW09,ST14] turns the quest of finding a ranking function to witness termination into a problem that is suitable for systematic search.Second, the progress in satisfiability (SAT) solving makes it possible to solve many seemingly difficult combinatorial problems efficiently in practice.Their combination, i.e., using SAT solvers to find interpretations, has so far been an effective strategy in solving challenging termination problems.
We make the following contributions: • We show how a generalized Collatz function can be expressed as a rewriting system that is terminating if and only if the function is convergent.
• We prove that no termination proof via natural matrix interpretations exists for a certain system by Zantema [Zan05] that simulates the Collatz function using unary representations of numbers.This result holds even when natural matrix interpretations are used in conjunction with the dependency pair transformation [AG00].
• We show that translations into rewriting systems that use non-unary representations of numbers are more amenable to automated methods, compared with the previously and commonly studied unary representations.
• We automatically prove various weakenings of the Collatz conjecture.We observe that, for some of these weakenings, the only matrix interpretations that our termination tool was able to find involved relatively large matrices (of dimension 5).Existing termination tools often limit their default strategies to search for small interpretations as they are tailored for the setting where the task is to quickly solve a large quantity of relatively easy problems.We make the point that, given more resources, the method of matrix interpretations has the potential to scale.
• We observe that the phase-saving heuristic used by default in modern SAT solvers can degrade the performance of CDCL (conflict-driven clause learning) solvers [MS99] on formulas encoding the existence of matrix interpretations, whereas using negative branching can improve solver performance.
In Appendix C, we present adaptations of our rewriting system that allow reformulating several more open problems in mathematics as termination problems of small size.

String Rewriting Systems
We briefly review the notions related to string rewriting that are used in the rest of the paper.We adopt the notation of Zantema [Zan05] and Endrullis et al. [EWZ08].For a comprehensive introduction to string or term rewriting, see Book and Otto [BO93] or Baader and Nipkow [BN98], respectively.
Definition 2.1 (String rewriting system).Let Σ be an alphabet, i.e., a set of symbols.A string rewriting system (SRS) over Σ is a relation R ⊆ Σ * × Σ * .Elements ( , r) ∈ R are called rewrite rules and are usually written as → r.The system R induces a rewrite relation → R := {(s t, srt) | s, t ∈ Σ * , → r ∈ R} on the set Σ * of strings.Definition 2.2 (Termination).A relation → on A is terminating if there is no infinite sequence s 0 , s 1 , . . .∈ A such that s i → s i+1 for all i ≥ 0. A terminating relation is also commonly called Noetherian, well-founded, or strongly normalizing.We write SN(→) to denote that → is terminating.
We often conflate an SRS R with the rewrite relation it induces when discussing termination.In particular, we write "R is terminating" instead of "→ R is terminating".We also often do not specify the alphabet and take it to be the set of all the symbols that appear in a given rewriting system.
1. R 1 = {aa → a} is terminating, which is proved easily by observing that each rewrite decreases the length of a string by 1.
2. R 2 = {a → aa} is not terminating, since even a single occurrence of a allows indefinitely producing more of the symbol a.
3. R 3 = {ab → ba} is terminating, since all rewrite sequences eventually convert a given string into the form b * a * and stop.An example sequence is shown below, with the underlines indicating the substrings that the rules are applied to.
A useful generalization of termination is relative termination: Definition 2.4 (Relative termination).Let → 1 , → 2 be relations on A. Then → 1 is said to be terminating relative to → 2 if there is no infinite sequence s 0 , s 1 , . . .∈ A such that • s i → 1 s i+1 for infinitely many values of i, • s i → 2 s i+1 for all other values of i.
Equivalently, R is said to be terminating relative to S if every sequence of rewrites for the system R ∪ S applies the rules from R at most finitely many times.Note that we have SN(R / ∅) = SN(R) by the definition, so relative termination is indeed a generalization.
Example 2.5.Let R = {aa → aba} and S = {b → bb}.The system R ∪ S is not terminating since S gives way to infinite rewrite sequences; however, R is terminating relative to S because R by itself is terminating and applying the rule b → bb does not facilitate further applications of the rule aa → aba.
Relative termination allows proofs of termination to be broken into steps as codified by the following theorem.
Theorem 2.6 (Rule removal [Zan05, Theorem 1]).Let R be an SRS.If there exists a subset T ⊆ R such that SN(T / R) and SN(R \ T ), then SN(R).
This theorem allows us to "remove rules" in the following way.When proving SN(R), if we succeed at finding a subset T satisfying SN(T / R), the proof obligation becomes weakened to SN(R \ T ), where the rules of T are no longer present.This removal of rules can be repeated until no rules remain, thus producing a stepwise proof of termination.
Another useful technique is reversal: Definition 2.7 (Reversal).Let s = s 1 . . .s n ∈ Σ * be a string and R be an SRS.Letting s rev := s n . . .s 1 , the reversal of R is defined as Lemma 2.8 (Rule reversal [Zan05, Lemma 2]).Let R, S be SRSs.Then, SN(R / S) if and only if SN(R rev / S rev ).
Reversal is of interest because methods for proving termination are not necessarily invariant under reversal, that is, a given technique may fail to show the termination of a system R while succeeding for its reversal R rev .
Yet another important notion is top termination: Definition 2.9 (Top termination).Let R be an SRS over Σ.The top rewrite relation induced by R is defined as In plain language, top termination allows rewrites to be performed only at the leftmost end of a string, so it requires a condition less strict than that of termination.As we will see in the next section (Theorem 2.15), top termination problems can admit proofs of a more relaxed form compared with termination.
Relative top termination, i.e., proving SN(R top / S) for SRSs R and S, is a crucial component in the dependency pair approach [AG00], which reduces a termination problem to a relative top termination problem that often ends up being easier to solve via automated methods compared with the original problem.In order to avoid requiring familiarity with the dependency pair approach, we omit its discussion and instead prove a self-contained result (Lemma 3.18) that encapsulates dependency pairs in a more elementary manner for the specific rewriting systems that we consider in this paper.

Interpretation Method
Let R be an SRS over the alphabet Σ.The main idea when proving termination is to show that there exists a well-founded (strict) order > on Σ * such that, for all strings s, t ∈ Σ * , if s → R t then s > t.When this is the case, R is terminating since any rewrite causes a "strict decrease" with respect to > and by its well-foundedness there cannot exist an infinitely decreasing sequence.The condition over infinitely many strings can be replaced by another one that involves only the rules of R by employing a reduction order [BN98, Section 5.2; BO93, Section 2.2].
Definition 2.10 (Reduction order).Let > be a well-founded order on Σ * .If for all s, t, p, q ∈ Σ * , s > t implies psq > ptq, then > is called a reduction order.
Theorem 2.11 ([BN98, Theorem 5.2.3;BO93, Theorem 2.2.4]).Let R be an SRS over the alphabet Σ.The system R is terminating if and only if there exists a reduction order > on Σ * such that > r holds for all → r ∈ R.
The interpretation method is a particular way of defining a reduction order.Instead of considering the strings directly, we interpret each symbol σ ∈ Σ as a function [σ] : A → A, where A is some carrier set, for example of natural numbers or vectors, and we extend this interpretation from symbols to strings s = s 1 . . .
When the domain A is already equipped with a well-founded order >, we can define a well-founded order where For appropriately chosen interpretations, > A ends up being a reduction order: Theorem 2.12 ([BN98, Theorem 5.3.3]).Let Σ be an alphabet and let > be a well-founded order on A. If for all symbols σ ∈ Σ the interpretation [σ] : A → A is monotone with respect to >, then > A as defined in (1) is a reduction order on Σ * .
Thus, after fixing (A, >), proving termination reduces to finding suitable (monotone) interpretations of the symbols as functions [for details see BN98, Section 5.3]. 3 As a concrete example, here is a simple proof of termination via the interpretation method.
Example 2.13.Recall R 3 = {ab → ba} from Example 2.3 with Σ = {a, b}.Fix (N + , >) with the usual order on positive integers, which is well-founded by the well-ordering principle. Let Both functions are monotone with respect to >, so by Theorem 2.12 the relation is a reduction order.For the rule ab → ba, since holds for all x ∈ N + , we have ab > N ba.Thus, by Theorem 2.11 the SRS R 3 is terminating.
In order to use the interpretation method for relative termination (resp.top termination), the above ideas can be generalized in the form of extended (resp.weakly) monotone algebras [EWZ08].
) is a weakly monotone Σ-algebra if for every σ ∈ Σ the interpretation [σ] is monotone with respect to .It is an extended monotone Σ-algebra if, additionally, for every σ ∈ Σ the interpretation [σ] is monotone with respect to >.
Relative termination (resp.top termination) is characterized as the existence of extended (resp.weakly) monotone algebras.
Theorem 2.15 ([EWZ08, Theorem 2]).Let R and S be SRSs over the alphabet Σ.We have SN(R / S) (resp.SN(R top / S)) if and only if there exists an extended (resp.weakly) monotone An effective way to automatically prove relative termination (or top termination) is to try to satisfy the conditions of the above theorem by fixing (A, >, ) and algorithmically searching for appropriate interpretations of the symbols.Matrix interpretations is a specific instance of this generic method.In the following section we describe (at a high level) the method of matrix interpretations.For more details and background, we refer the reader to existing work [HW06,EWZ08,KW09,ST14].
It may seem an odd choice to focus on matrix interpretations and implement our own prover given that there is a wealth of other techniques for proving termination that are already implemented in the existing tools (e.g., We did experiment with other methods; however, at least for the rewriting systems of the specific form in this paper it appears that the method of matrix interpretations is the most effective.For instance, one of the most difficult instances in this paper (in the sense of the smallest proof of termination that we could find) appears to require arctic matrix interpretations in all the proofs that we (and the authors of AProVE and Matchbox) could find.(There remain some versions of matrix interpretations that we have not yet experimented with [CGP10,NM11].) Additionally, we chose to implement our own minimal prover to have finer control over the SAT solving aspect of the search for an interpretation.We give a summary of our findings regarding this topic in Section 4.6.

Natural Numbers
Let R be an SRS over the alphabet Σ. Fix a dimension d ∈ N + .In the method of natural matrix interpretations [EWZ08] we set A = N d and define, for vectors x, y ∈ N d , x > y ⇐⇒ x 1 > y 1 ∧ x i ≥ y i for all i ∈ {2, . . ., d}, x y ⇐⇒ x i ≥ y i for all i ∈ {1, . . ., d}.
For interpreting each symbol σ ∈ Σ, we consider an affine function [σ] : In this way, the structure (N d , [•] Σ , >, ) satisfies the requirements of Definition 2.14 for a weakly monotone algebra.Additionally setting (M σ ) 1,1 = 1 satisfies the requirements for an extended monotone algebra.
Furthermore, since the composition of affine functions is affine, for all s ∈ Σ * there exist As a result, given a collection [•] Σ of natural matrix interpretations, the conditions of Theorem 2.15 can be checked by computing for each rule → r ∈ R the corresponding matrices M , M r and vectors v , v r and comparing them elementwise [EWZ08,Lemma 4].Extend to matrices M, N ∈ N d×d as M N ⇐⇒ M i,j ≥ N i,j for all i, j ∈ {1, . . ., d}.

Then, we have
This shows that it is decidable to check whether a given collection of interpretations of the form considered here constitutes a proof of termination.
The following functions constitute a matrix interpretations proof that shows SN(R / S).
[a](x) = 1 1 0 0 It is easy to check that the above interpretations give an extended monotone algebra and that they satisfy the below relations for all x ∈ N 2 , which implies SN(R / S) via Theorem 2.15.
[aa](x) = 1 1 0 0 In order to automate the search for matrix interpretations given a rewriting system R, an approach that turns out to be effective is to encode all of the aforementioned constraints as a propositional formula in conjunctive normal form and use a SAT solver to look for a satisfying assignment.This additionally involves fixing a finite domain for the coefficients that can occur in the interpretations and encoding arithmetic over the chosen finite domain using propositional variables.(We discuss our choice of encoding in Section 4.6.)

Arctic Integers
Natural matrix interpretations can also be adapted to the max-plus algebra of arctic4 natural numbers A N = N ∪ {−∞} or arctic integers A Z = Z ∪ {−∞} as coefficients.This adaptation enables termination proofs in some cases where either there is no other automated method that leads to a proof or only relatively complicated proofs are known [KW09].
Let R be an SRS over the alphabet Σ, and let A be either one of A N or A Z .In the method of arctic matrix interpretations [KW09,ST14] we use the arctic semiring (A, ⊕, ⊗), with the following operations: x ⊕ y = max{x, y} x ⊗ y = x + y Let > Z and ≥ Z denote the usual order relations over integers.Adopting the conventions that x > Z −∞ for all x ∈ Z and that −∞ ≥ Z −∞, we define, for x, y ∈ A, We fix a dimension d ∈ N + and we extend both and ≥ to arctic vectors and arctic matrices elementwise.As these definitions allow −∞ −∞, the order is not well-founded.To ensure well-foundedness of we restrict the domain to N × A d−1 .Then, for interpreting each symbol σ ∈ Σ, we consider an affine function [σ] : A d → A d , written as where we require In this way, the structure (N × A d−1 , [•] Σ , , ≥) satisfies the requirements of Definition 2.14 for a weakly monotone algebra.Additionally choosing A = A N and setting each v σ to be the −∞ vector (consequently enforcing (M σ ) 1,1 ≥ 0) satisfies the requirements for an extended monotone algebra.This means that arctic integers (as opposed to arctic natural numbers) and vectors that contain finite elements (i.e., not all −∞) are used only when proving top termination.
As the composition of affine functions over arctic vectors is affine, given a collection [•] Σ of arctic matrix interpretations we can compute for each rule → r ∈ R the corresponding arctic matrices M , M r and arctic vectors v , v r .Elementwise comparisons of these matrices and vectors give sufficient conditions for the inequalities in Theorem 2.15.In particular, due to Koprowski and Waldmann [KW09, Lemma 6.5], we have Thus, the search for arctic matrix interpretations can be automated in a manner similar to natural matrix interpretations by encoding the aforementioned constraints as a SAT instance.
b → ax aax → bxa ab → ba xb → ax a → ax As an example of the different capabilities of arctic versus natural matrix interpretations, consider trying to prove the relative termination statement SN({ b → ax} / P).To our knowledge, there is no direct proof of this statement via natural matrix interpretations although there is one via the 4-dimensional arctic matrix interpretations below.In the interpretations, − indicates −∞, and the multiplication operator ⊗ as well as the vectors of all −∞s are omitted.
With the above interpretations, the rules of P satisfy the following relations, which, by Theorem 2.15, proves that { b → ax} is terminating relative to P.
Definition 2.18 (Generalized Collatz function).Let X be one of N, N + , or Z and define there exist an integer d ≥ 2 and rational numbers q 0 , . . ., q d−1 , r 0 , . . ., r d−1 such that for all 0 ≤ i ≤ d − 1 and all n ∈ X, we have a definition In the above definition, we allow the representation of a partially defined function by mapping to ⊥ in the undefined cases.We call a partial f convergent if all f -trajectories contain ⊥.
Note that the Collatz function corresponds to the case d = 2, q 0 = 1/2, r 0 = 0, q 1 = 3, r 1 = 1.Although the Collatz function is by far the most widely studied case, there are several other concrete examples of generalized Collatz functions the convergence of which is worth studying due to their connections to open problems in number theory and computability theory.We discuss these cases in Appendix C.

Rewriting the Collatz Function
We start our discussion with systems that use unary representations and then demonstrate via examples that mixed-base representations can be more suitable for use with automated methods.

Rewriting in Unary
The following system of Zantema [Zan05] simulates the iterated application of the Collatz function to a number represented in unary, and it terminates upon reaching 1.
Example 3.1.Z denotes the following SRS, consisting of 5 symbols and 7 rules.
This system can be seen as encoding the execution of a Turing machine with cells that can be contracted/expanded.The symbols 1 and (blank) form the tape alphabet, while the symbols h (half), s (shift), t (triple) indicate the head along with the state of the machine.Through the following result, the Collatz conjecture can be reformulated as termination of string rewriting.
While the forward direction of the above theorem is easy to see (since h1 2n → * Z h1 n for n > 1 and h1 2n+1 → * Z h1 3n+2 for n ≥ 0), the backward direction is far from obvious because not every string corresponds to a valid configuration of the underlying machine.
As another example, consider the system below, which follows a theme similar to Example 3.1.
Example 3.3.W denotes the following SRS, consisting of 4 symbols and 4 rules.
Johannes Waldmann shared the above system (originally due to Zantema6 ) with us, mentioning that its termination has yet to be proved via automated methods.Nevertheless, there is a simple reason for its termination: It simulates the iterated application of a partial generalized Collatz function W : N + ⊥ → N + ⊥ defined as follows, which is easily seen to be convergent.

Nonexistence of Proofs via Natural Matrix Interpretations
Natural matrix interpretations cannot be used to directly remove any of the rules from the above kind of unary rewriting systems that simulate certain maps, in particular the Collatz function.
Definition 3.4 (N-rational sequence).A sequence x 1 , x 2 , . . .∈ N is called N-rational if there exists a matrix M ∈ N d×d and vectors v, w ∈ N d of some dimension d such that, for all n, we have The following is a consequence of Berstel's theorem [RB10, Theorem 8.1.1].(See also the remark by Soittola [Soi76, page 318].)Theorem 3.5.Let x 1 , x 2 , . . .be an N-rational sequence.Then there exist m, p ∈ N such that, for all j ∈ {0, 1, . . ., p − 1}, each of the subsequences {x m+kp+j } ∞ k=0 has its nth element equal to (1 + o(1))P (n)α n for some nonzero polynomial P and a constant α > 0. In particular, each of these subsequences is monotonically nondecreasing after some finite point.
Proof7 .Let p be as in Theorem 3.5, and consider n of the form qp − 1 for some large enough q.Then (9n + 2) − 8n + 1 = n + 1 = qp, so x 8n+1 and x 9n+2 belong to the same subsequence.This means that for all sufficiently large n of this form, we must have x 8n+1 ≤ x 9n+2 .
To make use of the above facts in ruling out the existence of natural matrix interpretations of the form described in Section 2.3.1, we also need the following result proving that we can work with interpretations that are purely linear (instead of affine) by moving up to a higher dimension.
Theorem 3.7 ([EWZ08, Theorem 6]).Let R be an SRS over the alphabet Σ, and let where 0 denotes the d-dimensional zero vector.For each rule → r ∈ R, let M , M r , v , v r , D , D r denote the matrices and the vectors occurring in the corresponding interpretations (as obtained by composing the interpretations of the symbols).
In informal terms, the above theorem states that if we have a collection of affine interpretations to remove a rule from a system (due to the strict decrease across the first elements of the corresponding two vectors), then there is also a collection of purely linear interpretations such that the top-right elements decrease strictly across the two matrices corresponding to this rule.With this fact at hand, we can prove the following.
Theorem 3.8.Let Σ = {1, , h, s, t}.There exists no collection [•] Σ of natural matrix interpretations of any dimension d satisfying the requirements for an extended monotone Σ-algebra such that • for at least one rule → r ∈ Z we have [ ](x) > [r](x) for all x ∈ N d , and Proof.Assume for a contradiction that such a collection of natural matrix interpretations exists for some dimension d − 1, with each symbol σ ∈ Σ interpreted as [σ](x) = M σ x + v σ and each matrix D σ defined as in Theorem 3.7.Let → r ∈ Z be a rule for which [ ](x) > [r](x) for all x ∈ N d−1 , and denote ρ = { → r}.As the interpretations satisfy the requirements for extended monotonicity, for all In Zantema's system Z, we can represent an arbitrary integer k by the string h1 k , interpreted as the ith standard basis vector, i.e., with 1 at the ith position and 0s elsewhere.Define where v = D T h e 1 and w = D e d are fixed, so f (1), f (2), . . . is an N-rational sequence.Now, since the system Z simulates the Collatz function (with the odd case incorporating an additional division by 2), for all numbers of the form 8n + 1 it can simulate the sequence of mappings 8n + 1 → 12n + 2 → 6n + 1 → 9n + 2 that results from applying the Collatz map three times.Thus, for all n, we have which crucially requires the use of every single rule in Z (as it involves applying both m → m/2 and m → (3m + 1)/2).This implies in particular that the rule → r is used in the above derivation.Recall also that the interpretations of all rules in Z are at least nonstrictly decreasing by assumption.This means along with (3) that, letting s = h1 8n+1 and t = h1 9n+2 , we have but we already argued in Corollary 3.6 that no N-rational sequence can satisfy this inequality for all n, contradiction.
Natural matrix interpretations fail to be useful for the unary rewriting systems even when used in conjunction with dependency pairs.For the reader familiar with dependency pairs, we show how to adapt the above proof to go through in the setting where the dependency pair transformation is applied before searching for natural matrix interpretations.Recall that, for an SRS R over Σ, letting DP(R) denote the SRS consisting of all dependency pairs of R as defined by Arts and Giesl [AG00, Definition 3], we have SN(R) if and only if SN(DP(R) top / R) [AG00, Theorem 6].For a defined symbol s ∈ Σ, we write s # to denote the corresponding tuple symbol.
Let I = { # s → # h, # t → # h}, and note that I ⊆ DP(Z).With an automated termination prover, the following is straightforward to establish for Zantema's system Z after applying the dependency pair transformation and performing several steps of rule removal (e.g., using natural matrix interpretations).
We prove below that neither rule in I can be removed using natural matrix interpretations.The proof is similar to that of Theorem 3.8, so we keep it relatively brief.
Theorem 3.10.Let Σ = {1, , # , h, s, t}.There exists no collection [•] Σ of natural matrix interpretations of any dimension d satisfying the requirements for a weakly monotone Σ-algebra such that • for at least one rule → r ∈ I we have [ ](x) > [r](x) for all x ∈ N d , and Proof.Assume for a contradiction that such a collection of natural matrix interpretations exists for some dimension d − 1, with each symbol σ ∈ Σ interpreted as [σ](x) = M σ x + v σ and each matrix D σ defined as in Theorem 3.7.Let → r ∈ I be a rule for which [ ](x) > [r](x) for all x ∈ N d−1 , and denote ρ = { → r}.As the interpretations satisfy the requirements for only weak monotonicity, for all s, t ∈ Σ * , if s We represent an arbitrary integer k by the string # h1 k , interpreted as Similar to (4), we let e i ∈ N d denote the ith standard basis vector and define g(k # h e 1 and w = D e d are fixed, so g(1), g(2), . . . is an N-rational sequence.For all n, we have , which crucially requires the use of both rules in I, and, moreover, these rules are applied only at the leftmost end of a string.In particular, the rule → r is used in the above derivation to perform a top rewrite.Thus, by (5), for all n, we have g(8n + 1) > g(9n + 2), which contradicts Corollary 3.6.
Analogues of Theorems 3.8 and 3.10 also hold for the system Z rev , with its rules reversed. 8Moreover, by arguments similar to above, we can show that natural matrix interpretations fail to prove the termination of W. It is natural to expect that if a proof of the Collatz conjecture is to be produced by some automated method that relies on rewriting, then that method better be able to prove a statement as simple as the convergence of W .With this in mind, we describe an alternative rewriting system that simulates the Collatz function and terminates upon reaching 1.We then provide examples where the alternative system is more suitable for use with termination tools (for instance allowing a matrix interpretations proof of the convergence of W ). The arguments in this section that prove Theorems 3.8 and 3.10 also appear not to apply to the alternative system, because the connection between rewrite sequences and N-rational sequences gets lost when not using unary representations.More specifically, the proofs crucially use the fact that, since the system Z represents numbers in unary, it is possible to form a sequence such that the nth element is represented by some product v T M n w, where v and w are vectors and M is a matrix.There is no single such matrix that one can extract when using mixed binary-ternary, or even just binary, representations.Thus, the same kind of analysis, which uses the results known about N-rational sequences, does not go through for the alternative system.

Rewriting in Mixed Base
In the mixed-base scheme, the overall idea is as follows.Given a number n ∈ N + , we write a mixed binary-ternary representation for it (noting that this representation is not unique).With this representation, as long as the least significant digit is binary, the parity of the number can be recognized by checking only this digit, as opposed to scanning the entire string when working in unary.This allows us to easily determine the correct case when applying the Collatz function.If the least significant digit is ternary, then the representation is rewritten (while preserving its value) to make this digit binary.Afterwards, since computing n/2 corresponds to erasing a trailing binary 0 and computing 3n + 1 corresponds to inserting a trailing ternary 1, applying the Collatz function takes a single rewrite step.
Intuitively, the rewriting system we present can be seen as applying the Collatz map to natural numbers written in binary, with some secondary computation performed using auxiliary symbols to facilitate the application of the map n → 3n + 1.However, since termination of rewriting is concerned with sequences that arise from any initial string and any possible application of the rules, we need to consider the behavior of the system over any string that may be encountered, which includes even the strings that could not result from computing in binary with a prescribed strategy for rule application.The mixed-base scheme is simply a way to give an arithmetical meaning to all strings and all possible rewrite steps.
More formally, a mixed-base numeral system [Can69] is a numeral system where the base changes across positions, which we define as follows.
is called a mixed B-ary representation.To reduce clutter, we identify the matrix N with a string The string N in the above definition represents the number Observing that the addition of leading zeros (symbols 0 b for any b) to a string does not change its value, we may assume without loss of generality that n 1 > 0. Furthermore, b 1 does not affect the value of the string, so we replace it by zero (noting that by Definition 3.11 no other base is zero).
1.With B = {2}, we have the binary numeral system.In the notation of Definition 3.11 we write 1 2 0 2 1 2 1 2 to represent the number 11.
2. With B = {2, 3}, we obtain the mixed binary-ternary system that we will use in the rest of this paper.In this system we may write, for instance, 1 0 2 3 1 2 or 2 0 1 2 1 2 or 1 0 1 2 2 3 to represent the number 11.Now, define β n b (x) := bx + n.After rearranging (6), we see that for a mixed B-ary string at any value (because b 1 = 0 implies that the innermost function β n 1 0 (x) = n 1 is constant).This gives us a string and a function view of the same representation, and we will switch between them as appropriate.In doing so, we also conflate the symbols and the corresponding functions, referring to β n b as n b .As the last ingredient before describing the rewriting system, we observe that we can write From this point on, we constrain ourselves to the mixed {2, 3}-ary (binary-ternary) representations as we shift our focus to simulating the Collatz function (noting that it is possible to adapt the resulting rewriting system for other instances of the general case).More precisely, we simulate the following redefinition of the Collatz function, where the odd case incorporates an additional division by 2.
We will describe an SRS T over the symbols {f, t, 0, 1, 2, , } that simulates the iterated application of the Collatz function and terminates upon reaching 1.The symbols f, t correspond to binary digits 0 2 , 1 2 ; and 0, 1, 2 to ternary digits 0 3 , 1 3 , 2 3 .The symbol marks the beginning of a string while also standing for the most significant digit (without loss of generality assumed to be 1 0 ) and marks the end of a string while also standing for the redundant trailing digit 0 1 .Consider the functional view of these symbols: Each positive integer can be expressed as some composition of these functions, which corresponds to a string as per our previous discussion.
Example 3.13.Viewing the expression (x) as the constant 1, we can write The string representation ends with a ternary symbol, so we will rewrite it.
With the function view, we have This shows that we could also write 19 = Val( 00t ), which now ends with the binary digit 1 2 .This gives us the rewrite rule f1 → 0t.We can now apply the Collatz function to this representation by rewriting only the rightmost two symbols of the string since This gives us the rewrite rule t → 2 .After applying this rule to the string 00t , we indeed obtain T (19) = 29 = Val( 002 ).
In the manner of the above example, we compute all the necessary transformations and obtain the following 11-rule SRS T .
This SRS is split into subsystems D T (dynamic rules for T ) and X = A ∪ B (auxiliary rules).The two rules in D T encode the application of the Collatz function T , while the rules in X serve to push binary symbols towards the rightmost end of the string by swapping the bases of adjacent positions without changing the represented value.
Example 3.14 (Rewrite sequence of T ).Consider the string s = ff0 , which represents the number 12. Below is a possible rewrite sequence of T that starts from s, with the corresponding values (under the interpretations from (8)) displayed above the strings.Underlines indicate the parts of the strings where the rules are applied.
12 12 6 6 3 3 5 5 The trajectory of T would continue upon reaching 1; however, in order to be able to formulate the Collatz conjecture as a termination problem, T is made in such a way that its rewrite sequences stop upon reaching the string representation of 1 since no rule is applicable.Termination of the subsystems of T with B or D T removed is easily seen.However, since we have matrix interpretations at our disposal, let us give a compact and formal proof.Proof.It is easily checked that the interpretations below show SN((T \ B) rev ), which implies SN(T \ B) by Lemma 2.8.
Similarly, the below interpretations show SN((T \ D T ) rev ), which implies SN(T \ D T ) by Lemma 2.8.
When considering the termination of T (on all initial strings), it suffices to limit the discussion to initial strings of a specific form that we have been working with so far, e.g., in Examples 3.13 and 3.14.Lemma 3.16.If T is terminating on all initial strings of the canonical form (f|t|0|1|2) * , then T is terminating (on all initial strings).
For the proof of Lemma 3.16, we will use type introduction, which is a technique for proving termination by switching to typed rewriting.We refer the reader to Sabel and Zantema [SZ17, Section 3.1] for background.We also offer a more elementary proof in Appendix A.
Proof of Lemma 3.16.Let T = {ρ, σ, τ } be a set of types.It is straightforward to see that, with respect to the typing the SRS T is well-typed, so it is terminating (in the untyped setting) if and only if it is terminating in the typed setting [SZ17, Corollary 3.4].Due to Lemma 3.15, a well-typed string with σ as its source or target type cannot admit an infinite rewrite sequence for T .Thus, a well-typed string admits an infinite rewrite sequence only if it is of type ρ → τ , which implies that it is of the canonical form.
Note that the converse of the above lemma is obvious, since if T is terminating then it is terminating on all initial strings of any form, in particular (f|t|0|1|2) * .
As a whole, the rewriting system T simulates the iterated application of T (except at 1).
Theorem 3.17.T is terminating if and only if T is convergent (i.e., the Collatz conjecture holds).
Proof.Without loss of generality (due to Lemma 3.16), consider only the strings of the canonical form (f|t|0|1|2) * throughout this proof.We will show that, given such a string N , all rewrite sequences for T that start from N simulate the T -trajectory of Val(N ), except when Val(N ) = 1.
More specifically, we prove the following and use them to deduce the theorem statement.
This holds if and only if Γ r = Γ for all → r ∈ X .With the functional views of the symbols as in (8), we indeed have: This proves the first part of the claim.Now assume N → D T N .Again, there exist a string X and some rule → r ∈ D T such that N = X and N = Xr (since the rules in D T can be applied only at the rightmost end of the string).We have This holds if and only if Γ r = T • Γ for all → r ∈ D T .There are only two rules to check, and indeed we have: This proves the second part of the claim.
Proof of Claim 2. The string has Val( ) = 1, and inserting any symbol from {f, t, 0, 1, 2} in between the delimiters increases the value of the string, so is the unique string representing 1.None of the rules in T apply to , which proves the claim.
Proof of Claim 3. Let ν > 1 be an integer, and let N be a string with Val(N ) = ν.We will describe a rewrite sequence N → * X N → D T N , which implies by Claim 1 that Val(N ) = T (ν).For the rest of the proof let b i and t i stand for binary and ternary symbols, respectively.Assume that N contains some binary symbol (f or t), since otherwise it is of the form (0|1|2) * and we can apply some rule from B to produce a binary symbol.Then the string contains some substring b 1 t 2 t 3 . . .t k .We rewrite this substring into t 1 b 2 t 3 . . .t k by applying some rule from X .For each 1 < i < k, assuming the current string contains some substring b i t i+1 . . .t k , we rewrite it into t i b i+1 t i+2 . . .t k .In the end we obtain a string N with Val(N ) = ν that contains some b k , so we apply some rule from D T to obtain N such that Val(N ) = T (ν).
Assume that the SRS T is not terminating.Let (N i ) ∞ i=0 be an infinite rewrite sequence for T , and consider the sequence (ν i ) ∞ i=0 , where ν i = Val(N i ).By Claim 1, for all i ∈ N, we have either which is the same as the set of indices at which some rule from D T is applied in the rewrite sequence.By Lemma 3.15, the subsystem X = T \ D T is terminating, so the rewrite → D T is performed infinitely many times in the sequence.This implies that I is infinite, proving that the sequence (ν i ) i∈I is a Collatz trajectory.Moreover, this trajectory is nonconvergent, i.e., it does not contain 1, since otherwise the rewrite sequence could not be infinite (because of Claim 2).This proves the backward implication in the theorem statement.
Assume that the function T is not convergent.Let (ν i ) ∞ i=0 be a nonconvergent trajectory, and note that ν i > 1 for all i ∈ N. We will inductively define a sequence (N i ) ∞ i=0 such that Val(N i ) = ν i for all i ∈ N. Let N 0 be any string with Val(N 0 ) = ν 0 .For each i ∈ N + , assuming Val(N i−1 ) = ν i−1 , let N i be a string such that N i−1 → * T N i and Val(N i ) = T (ν i−1 ) = ν i , which exists by Claim 3. Defined in this manner, the sequence (N i ) ∞ i=0 satisfies N i → * T N i+1 for all i ∈ N, meaning that T is not terminating.This proves the forward implication in the theorem statement, which concludes the proof.
When trying to remove a rule in D T or B it suffices to show relative top termination, allowing us to use weakly (instead of extended) monotone algebras when applying Theorem 2.15 and take advantage of the more relaxed constraints when searching for matrix interpretations.As we mentioned back in Section 2.1, the lemma below encapsulates dependency pairs, and it can in fact be automatically proved by the existing termination tools via the dependency pair transformation followed by an application of the dependency pair framework [GTSF06].9Lemma 3.18.
Proof.Without loss of generality (due to Lemma 3.16), consider only the rewrite sequences that start with some string of the canonical form (f|t|0|1|2) * (resp.its reversal).
Let R ⊆ B (resp.Q ⊆ D T ).The rules in R (resp.Q rev ) can be applied only at the leftmost end as they are all of the form s → t for some s, t not containing (resp.s → t for some s , t not containing ).
Assume ¬ SN(R / T ) (resp.¬ SN(Q rev / T rev )).Then there exists an infinite rewrite sequence for T (resp.T rev ) where the rules from R (resp.Q rev ) are applied infinitely many times.As these rules can be applied only at the leftmost end, this implies relative top nontermination, i.e., ¬ SN(R top / T ) (resp.¬ SN(Q rev top / T rev )).

Rewriting with a Hybrid System
As another alternative to the rewriting system Z, instead of fully discarding unary in favor of a positional numeral system we may adopt a hybrid between the two approaches and design a system to increment/decrement by 1 or multiply/divide by 2 or 3 in a single rewrite.We will describe an SRS over the symbols {i, f, 0, , } viewed as follows.
In essentially the same manner as we did for the system T , we have a set of dynamic rules that simulate the application of the Collatz function and a set of auxiliary rules that update the string representation so that the parity of the corresponding number can be recognized in a single step.We have the following 7-rule SRS L (designed by Luke Schaeffer).
As long as the string ends with f or fi , the parity of the represented number is apparent without needing to scan the whole string, which allows the Collatz function to be applied in a single rewrite.After the application of a dynamic rule, the string may no longer end with f or fi , so the auxiliary rules in X = A ∪ B push the symbol f towards the rightmost end of the string while preserving its value.Thus, L is yet another rewriting system that simulates the iterated application of the Collatz function.
Theorem 3.19.L is terminating if and only if T is convergent.
The proof of the above theorem is essentially the same as that of Theorem 3.17 once it is checked that the dynamic rules do indeed apply T and that the auxiliary rules do indeed preserve the value of a string under the functional view of the symbols.

Automated Proofs
We adapt the rewriting system T for different generalized Collatz functions to explore the effectiveness of the mixed-base scheme on weakened variants of the Collatz conjecture.
All of the rewriting systems, scripts to reproduce the proofs, and our minimal implementation of a termination prover are available at https://github.com/emreyolcu/rewriting-collatz.In particular, any omitted relative termination proof that we refer to in this section is available at https://github.com/emreyolcu/rewriting-collatz/tree/main/proofs.We ran the largescale experiments in this section on AWS EC2 m5.metal instances.

A Simple Example
Earlier we mentioned a generalized Collatz function W as a simple example that could serve as a sanity check for an automated method aiming to solve Collatz-like problems.With the mixed binary-ternary scheme, this function can be seen to be simulated by the system W = {f → 0 } ∪ X .A small matrix interpretations proof is found for this system in less than a second, in contrast to its variant W that uses unary representations for which no automated proof is known.Additionally, the function W can be simulated by the rewriting system W = {f → 0 } ∪ X adapted from the hybrid system L, although we were unable to find an automated proof of termination for W .

Proof. The interpretations below prove
With the above interpretations of the symbols, the rules of W rev satisfy the following relations, which, by Theorem 2.15, proves that { f → 0} is terminating relative to X rev .
By Lemmas 2.8 and 3.15, X rev is terminating.As a result, W rev is terminating, which by Lemma 2.8 implies that W is terminating.

Farkas' Variant
Let 2N + 1 = {1, 3, 5, . . .} denote the odd natural numbers.Farkas [Far05] studied a slight modification F : 2N + 1 → 2N + 1 of the Collatz function for which it becomes possible to prove convergence via induction.We consider automatically proving the convergence of this function as another test case for the mixed-base scheme that is easier than the Collatz conjecture without being entirely trivial.Farkas defined this function as if n ≡ 0 (mod 3) and n ≡ 1 (mod 4) 3n+1 2 if n ≡ 0 (mod 3) and n ≡ 3 (mod 4).
In this paper, we define another function F : N → N that resembles the Collatz function more closely than Farkas' F (with respect to the definitions of the cases) while being equivalent to F in terms of convergence.It is obtained by introducing an additional case in the Collatz function for n ≡ 1 (mod 3) and applying T otherwise: Given an F -trajectory, the bijection n → (n − 1)/2 applied to each of its iterates maps the trajectory to the corresponding F -trajectory.Thus, an F -trajectory reaches 1 if and only if the corresponding F -trajectory reaches 0. Furthermore, an F -trajectory reaches 0 if and only if it reaches 1, which is a convenient fact since in our string representations we do not represent 0, so in order to prove that F is convergent it suffices to show that for all n ∈ N + the trajectory F N (n) contains 1.
Note that F can also be viewed as a generalized Collatz function with 5 cases, which makes it straightforward to translate the cases of F into a set D F of dynamic rules (shown below) to obtain a rewriting system that simulates the iterated application of F on positive integers.
Termination of the rewriting system F = D F ∪ X is equivalent to the convergence of F .The proof of the equivalence is essentially the same as that of Theorem 3.17 except for the step where we construct a nonterminating rewrite sequence from a nonconvergent trajectory.To construct such a rewrite sequence for F, we take any nonconvergent F -trajectory and write the first number in the trajectory in ternary (instead of binary).If the leading digit turns out to be 2 3 we replace it by 1 0 0 2 since the leading digit is always assumed to be 1 0 in our mixed-base representations.Then repeatedly performing the rightmost possible rewrite results in a rewrite sequence that simulates the F -trajectory.
Farkas gave an inductive proof of convergence for F via case analysis.We found an automated proof that F is terminating via arctic matrix interpretations.Below, we present both a manual proof of convergence for F and the automated proof of SN(F).It is worth mentioning that the default configurations of the existing termination tools (e.g., AProVE, Matchbox) are too conservative to prove the termination of this system, but after their authors tweaked the strategies they were also able to find automated proofs via arctic matrix interpretations.It also remains an interesting question whether the automated proof somehow captures the argument in the inductive proof.
Proof (in the manner of Farkas [Far05, Theorem 1]).We proceed by induction.For n = 1 the result holds since F N (1) = (1, 0, 0, . . .).Assuming it holds for all positive integers less than n, we will show that it holds for n.In particular, we will show that the trajectory of n reaches a number strictly smaller than n, which implies by the induction hypothesis that the trajectory contains 1.We split into three cases.
(iii) Assume n ≡ 3 or n ≡ 5 (mod 6).Denote n by N 1 , and consider the trajectory We cannot have k = ∞, i.e., F cannot apply N → (3N + 1)/2 indefinitely, since for such a sequence we have As all the elements in the trajectory have to be integers, k − 1 cannot exceed the number of times that N 1 + 1 can be divided by 2, so k is finite.Consider It is of the form 3 k • L − 1 for some positive integer L, so we know that either N k+1 ≡ 2 (mod 6) or N k+1 ≡ 5 (mod 6).Due to the way k is defined, N k+1 cannot be congruent to 5 (mod 6), so we have N k+1 ≡ 2 (mod 6).In particular, N k+1 is even, so 3 2 is odd, which in turn implies that N 1 +1 2 k is odd, i.e., we have N 1 = 2 k • (2M + 1) − 1 for some natural number M .Then, N k+1 satisfies Since N k+1 ≡ 2 (mod 6), we can deduce that and furthermore, Repeatedly applying F in the above manner gives F 2k (N k+1 ) = 2M .Since k ≥ 1, we have 2M < 2 k • (2M + 1) − 1 = N 1 = n, and so the trajectory F N (n) reaches a number strictly smaller than n.
Proof (via arctic matrix interpretations).We will show SN(F).By Lemmas 2.8 and 3.15, we have SN(X rev ).Consider the arctic matrix interpretations below.Recall that − indicates −∞ in the matrices.Also recall that arctic addition is max and arctic multiplication is +. [ Above interpretations prove SN(D F rev top / X rev ) by Theorem 2.15.(See Appendix B for the corresponding interpretations of the rules of F rev .)We then get SN(D F rev /X rev ) by Lemma 3.18.As we know that X rev is terminating, by Theorem 2.6 we can conclude SN(D F rev ∪ X rev ), which implies SN(F) via Lemma 2.8.

Subsets of the Collatz System
It is also interesting to consider whether we can automatically prove termination of proper subsets of T .Specifically, we considered the 11 subsystems obtained by leaving out a single rewriting rule from T , and we found termination proofs via matrix interpretations for all of the 11 subproblems.
The reason for our interest in these problems is threefold: 1. Termination of T implies termination of all of its subsystems, so proving its termination is at least as difficult a task as proving termination of the 11 subsystems.Therefore, the subproblems serve as additional sanity checks that an automated approach aspiring to succeed for the Collatz conjecture ought to be able to pass.Furthermore, they form an additional source of weakened variants that give us a heuristic idea of the suitable choice of parameters to use when searching for interpretations for the full problem.
2. When proving termination in a stepwise manner, we solve a sequence of relative termination problems.Having proved termination of all 11 subsystems is a partial solution to the full problem, since it implies that for any single rule → r ∈ T , proving SN({ → r} / T ) settles the Collatz conjecture.
3. After the removal of a rule, the termination of the remaining system still encodes a valid mathematical question about the Collatz trajectories.The question of the termination of a proper subset is equivalent to asking if every corresponding Collatz trajectory that does not require the use of the left-out rule is convergent.For instance, removing {t → 2 } deletes the odd case of the Collatz function, which gives a clearly convergent function.
Removing the auxiliary rules in X lead to potentially more interesting questions: For instance, the termination of T \ {t1 → 2f} implies that the trajectories where the pattern t1 is never encountered during the simulation are all convergent.
Note that this type of inquiry is less meaningful for the unary system Z as its simulation of the Collatz function depends crucially on each rule being present.Leaving out some subset of the rules from Z causes the system to become terminating for a trivial reason, i.e., the computation it expresses no longer corresponds to the iterated application of some function.
Example 4.3.As an instance of leaving out a rule, consider the subsystem T \ {f1 → 0t}.
There is a single-step natural matrix interpretations proof that this system is terminating: It can be checked that under these interpretations the rules of T \ {f1 → 0t} satisfy the following relations: Note that the left-out rule f1 → 0t ends up receiving a nondecreasing interpretation as there is no constraint to enforce otherwise: The above interpretations witness for instance that the Collatz trajectory starting at 3 (represented as t ) is convergent, because the missing rule is not used in any derivation of 1 ( ) from 3. Below is an example derivation along with the values each string represents and a vector value of each string under the interpretations above (setting x = (0, 0) for the purpose of demonstration).We omit the subscripts from the rewrite relations and simply write →.
Table 1 shows the parameters of the matrix interpretations proofs that we found for the termination of each subsystem.For each rule → r that is left out, we searched for a stepwise proof to show that B \ { → r} is terminating relative to T \ { → r} (freely utilizing weakly monotone algebras due to Lemma 3.18).Such a proof requires at most three steps since there are at most three rules in B \ { → r}.In the table, we report the smallest parameters (in terms of matrix dimension) that work for all of these steps.As we already know that SN(T \ B) holds (by Lemma 3.15), the interpretations found allow us to conclude the termination of each subsystem.This is not the only way to prove termination of the subsystems; however, we chose this uniform strategy for the sake of comparison.In the experiments we searched for matrices of up to 7 dimensions, with the coefficients taking at most 8 different values.

Odd Trajectories
In the originally defined Collatz function C, applying 2n + 1 → 6n + 4 produces an even number, so we incorporate a single division by 2 into the definition of the odd case and obtain the Table 1: Smallest proofs found for termination of subsystems of T in under 30 seconds.The columns show the matrix dimension D and the maximum number V of distinct coefficients that appear in the matrices, along with the median time to find an entire termination proof across 25 repetitions for the fixed D and V .

Natural Arctic
Rule removed D V Time D V Time In this sense, it has the same overall dynamics as the Collatz functions C or T we have previously defined, i.e., Syr is convergent if and only if C or T is convergent.The function T takes fewer steps than C to reach 1 and can be thought of as an accelerated Collatz function, making the Syracuse function a further accelerated version.Reducing the number of steps towards convergence is of interest mainly because the existence of various kinds of termination proofs is dependent on the derivational complexity10 of the rewriting system staying below certain thresholds [HL89].For instance, given a rewriting system, if its termination can be proved in a single-step via natural matrix interpretations then its derivational complexity is at most exponential [EWZ08].Similarly, a single-step termination proof via arctic matrix interpretations implies a linear derivational complexity [KW09].Thus, it can be preferable to work with an alternative rewriting system with smaller derivational complexity that still simulates the dynamics of the Collatz function.
Expressing the Syracuse function as a generalized Collatz function would require infinitely many cases to account for all of the possible appearances of 2 k as the denominator with different values of k.As a result, we are unable to simulate it with a finite rewriting system.Nevertheless, we may compromise and accelerate the Collatz function by a smaller amount.
We can prove automatically via matrix interpretations that S 3 = S \ {t• → 2•} is terminating, which implies the following through an equivalence of the above form for S 3 .Proposition 4.6.All nonconvergent S-trajectories contain some n ≡ 3 (mod 4).
Leaving out some dynamic rules from a mixed-base rewriting system that simulates a generalized Collatz function allows us to phrase the above kinds of questions as termination problems.Recall that, although S is equivalent to C in terms of convergence, its trajectories are not necessarily contained in the Collatz trajectories, so we cannot substitute C for S in the above statements (except for the second item of Proposition 4.5, since the left-out rule is the one that maps to a number not contained in the Collatz trajectory).In the next section, we perform the same kind of inquiry into the original Collatz trajectories.Our initial motivation for the previous section was to find rewriting systems with reduced derivational complexity.This inquiry led us to surprisingly difficult Collatz-like problems, which we believe may be on the border of the reach of automated methods.In this section we explore more problems of a similar form and present the unsolved ones as potentially reachable targets for automated termination proving.

Collatz Trajectories Modulo
Let m be a power of 2. Given k ∈ {0, 1, . . ., m − 1}, is it the case that all nonconvergent Collatz trajectories contain some n ≡ k (mod m)?For several values of k this can be proved by inspecting the transitions of the iterates in the Collatz trajectories across residue classes modulo m (shown on Figure 1 for m = 8).As an example, consider the case k = 6.Proposition 4.7.All nonconvergent C-trajectories contain some n ≡ 6 (mod 8).
We start by studying the smallest interesting case m = 4. Consider the following two sets of dynamic rules to simulate the Collatz function.1. SN(C Even/4 \ {ff → f }) if and only if all nonconvergent C-trajectories contain some n ≡ 0 (mod 4).
We were able to prove termination of the above four systems via matrix interpretations, thus establishing the following.Theorem 4.9.If there exists a nonconvergent Collatz trajectory, it cannot avoid any of the residue classes modulo 4.
Next, we look at the case m = 8.It can be studied via the analogously defined rewriting systems: The SRS C Even/8 = D Even/8 C ∪ X simulates the function C and the SRS T Odd/8 = D Odd/8 T ∪ X simulates the function T .We do not formally state the analogue of Proposition 4.8terminations of the eight subsystems obtained from C Even/8 or T Odd/8 are each equivalent to the question of whether all nonconvergent Collatz trajectories have to encounter the corresponding residue class modulo 8. Through automated proofs, we were able to establish the following.
Theorem 4.10.If there exists a nonconvergent Collatz trajectory, it cannot avoid the residue classes of 2, 3, 4, 6 modulo 8. Theorems 4.9 and 4.10 are also not difficult to prove by hand; however, it remains open whether an analogue of Theorem 4.10 holds for the residue classes of 0, 1, 5, 7 modulo 8, that is, we have neither manual nor automated proofs for these cases.They may serve well as easier 11  Collatz-like open problems to test our abilities against, so we offer a $500 reward for a resolution of any of the following conjectures. 12Conjecture 4.11.All nonconvergent C-trajectories contain some n ≡ 1 (mod 8).
Even the following easier statement remains unproved, although we were able to prove (both manually and automatically) its versions with {1, 5} and {1, 7} as the residue classes.
We can alternatively formulate each of the above conjectures as the convergence problem of some partial generalized Collatz function.For instance, Conjecture 4.14 is equivalent to the convergence of the function H : N + ⊥ → N + ⊥ defined as follows.
if n ≡ 0 (mod 4) 9n+1 8 if n ≡ 7 (mod 8) ⊥ otherwise (10) 11 See Denend [Den18, Section 4] for a heuristic prediction of the relative easiness of those cases.Denend uses an empirical measure based on the number of odd elements occurring in a trajectory until either a certain residue class or 1 is encountered, which resembles the ones-ratio and the stopping time ratio defined by Applegate and Lagarias [AL03].
12 The case 0 is omitted as its answer follows from the case 5 by Figure 1.
Proof.Recall from Figure 1 the transition graph of the iterates in C-trajectories across residue classes modulo 8. Observe that if a nonconvergent trajectory avoids the residue classes of 5 and 7 (mod 8), then it has to visit the residue class of 1 (mod 8), so we may assume without loss of generality that each nonconvergent trajectory starts with some n ≡ 1 (mod 8).

SAT Solving Considerations
Phase-saving heuristic.Most top-tier termination tools, such as AProVE, Matchbox, and T T T 2 , use the SAT solver MiniSat [ES04] to search for matrix interpretations.This choice is somewhat surprising as MiniSat has not been updated since 2008 and the performance of SAT solvers has improved significantly in the last decade.The use of MiniSat in these provers is motivated by its observed effectiveness in finding interpretations.We investigated the reason for this, which turned out to be a heuristic that MiniSat disables in its default configuration.
Most SAT solvers sort variables by the frequency of their occurrences in recent conflict clauses, selecting the highest ranked one as the variable to branch on [MMZ + 01].This procedure is similar in MiniSat and modern SAT solvers.However, once a variable is picked, the solvers differ in the truth value assignment that they explore first.MiniSat uses negative branching [ES04], which explores the "false" branch first for all decision variables.The empirical effectiveness of this heuristic likely stems from its interaction with the common choices of propositional encodings used when translating problems into SAT instances.Modern SAT solvers use phasesaving [PD07], which first explores the branch corresponding to the truth value to which the variable was forced most recently during unit propagation.We offer the following explanation for the effectiveness of negative branching.
We use the order encoding [TTKB09, PJ11] when translating the integer constraints from Section 2.3 into CNF formulas.In this encoding, each variable X that takes values in a finite domain A = {0, 1, . . ., n + 1} is represented by a corresponding list of n + 1 Boolean variables (x 0 , x 1 , . . ., x n ).Each Boolean variable x i indicates X > i.As an example, X = 2 has the corresponding assignment (1, 1, 0, 0, . . ., 0).This encoding gives a natural way of representing inequality constraints.For instance, the constraint a < X ≤ b can be enforced simply by setting x a = 1 and x b = 0.As another example, for variables X, Y the inequality X ≤ Y can be expressed by the conjunction n i=0 (¬x i ∨ y i ).Consequently, when using the order encoding, representations that correspond to smaller numbers require setting a larger fraction of the Boolean variables to false.For instance, the representation of zero or minus infinity assigns all variables to false.Moreover, the matrices and the vectors that occur in the interpretations are often sparse and contain relatively few large numbers.As a result, negative branching possibly directs the search towards a satisfying assignment more often.
Additionally, in contrast to phase-saving, negative branching tends to guide the solver to a potentially different part of the search space after a restart (which is performed frequently in SAT solvers).The increased diversity of the search space (across restarts) that is explored due to negative branching is also possibly helpful for the kinds of the problems discussed in this paper.
One can enable negative branching in most SAT solvers, which in our case improves solver performance for some of the formulas that encode the existence of interpretations.
Heavy-tailed behavior of SAT solvers.Combinatorial search algorithms can have a tendency to show a large variance in runtime across different, randomly selected initial conditions of the search.For instance, Gomes et al. [GSCK00] observed that DPLL solvers [DP60, DLL62] had a substantial fraction of very short runs when dealing with relatively hard instances.This suggests that trying to solve such instances using several parallel runs is a reasonable strategy, since some of the runs will have a nonnegligible chance of finishing early.
Modern SAT solvers incorporate heuristics that alleviate the heavy-tailed behavior to some extent; however, the variability in runtime (especially on satisfiable instances) is not completely eliminated.In our termination prover, we run multiple instances of the SAT solver (specifically, CaDiCaL [Bie19]) in parallel on the formula that encodes the existence of an interpretation.We introduce additional randomness to the procedure by running each parallel instance with a different shuffling of the clauses in the formula.Ideally, solver performance would be invariant to the ordering of the clauses; however, the clause order indirectly affects the variable selection heuristic, which ends up influencing runtime.
Experiments with solver configurations.Table 2 shows the difference in runtime for both MiniSat and CaDiCaL due to negative branching and parallelism with a few small-scale experiments.From all the automated proofs in this paper, we selected the steps where the SAT solving phase took longer than 2 seconds, and reran the prover for these specific steps with different configurations of those SAT solvers.When running only a single instance of a solver, we used the nonshuffled formula.In the parallel case, we ran 8 solver instances with one of the instances receiving the nonshuffled formula and the other 7 receiving random shuffles.Running multiple instances of a solver in parallel is a considerable improvement in all cases where the allotted time is enough to find an interpretation.Negative branching has an adverse effect in some cases, although in two of the most difficult instances (F and C Even/8 \ {ttf → tt }) it makes the difference between finding an interpretation relatively quickly and timing out.It also appears that, at least for the more difficult cases, replacing MiniSat by CaDiCaL can be beneficial.These experiments are not extensive enough to derive broad conclusions; however, they suggest that running multiple instances of a modern SAT solver with negative branching enabled in some and disabled in others can be a reasonably diverse strategy when searching for matrix interpretations.
Table 2: Difference in runtime due to negative branching and parallelism.Each row corresponds to a single step of a relative termination proof occurring in the previous sections of this paper.The leftmost columns show the original system being proved as terminating, along with the parameters of the interpretations being searched for (D for dimension, V for the number of different values each coefficient may take) that remove at least a single rule from the system.For each solver, each of the remaining columns shows the median time the experiment takes over 25 repetitions.Each run times out after 120 seconds, and runs that time out are counted as having taken double the allowed time.

Related Work
There are several previous studies of the Collatz conjecture through alternative models of computation.
String rewriting systems.To our knowledge, Zantema [Zan05], with his system Z, which we saw in Section 3.1, was the first to attempt using an automated method and string rewriting to search for a proof of the Collatz conjecture.In addition, although we independently discovered the mixed binary-ternary system described in Section 3.2, Scollo [Sco05] had essentially the same idea, the distinction being that he adopted a functional view of the digits that is different than in (8).Scollo was not concerned with proving termination, though, and proposed rewriting primarily as a formalism that forgoes the arithmetic interpretation of the iterates and instead emphasizes the dynamic/computational behavior.interesting statements.We observed that some variants could be solved only via natural matrix interpretations, while others required arctic matrix interpretations.Several extensions to this work can further our understanding of the potential of rewriting techniques for answering mathematical questions.For instance, it is of interest to study the efficacy of different termination proving techniques on the problems that we considered.In particular, we found matrix interpretations to be the most successful for our purposes despite the existence of newer techniques developed for automatically proving termination of a few select challenging instances.Although matrix interpretations lead to automated proofs of several weakened variants discussed in this paper, it might still be the case that there exist no such interpretations to establish the termination of the Collatz system T (as we have shown in the case of natural matrix interpretations for Zantema's system Z).This would be an interesting result in itself.Another issue is the matter of representation; specifically, it is worth exploring whether there exists a suitable translation of the Collatz conjecture into the termination of a term, instead of string, rewriting system since many automated termination proving techniques are generalized to term rewriting.Finally, injecting problem-specific knowledge into the rewriting systems or the termination techniques would be helpful as there exists a wealth of information about the Collatz conjecture that could simplify the search for a termination proof.

B Remaining Part of the Automated Proof for Farkas' Variant
With the interpretations from (9), the rules of F rev satisfy the following relations:   It is an open problem whether all busy beavers are total Turing machines.In particular, it is unknown whether the current BB-5 candidate is total.Michel showed that the BB-5 candidate simulates the following generalized Collatz function.
if n ≡ 0 (mod 3) 5n+22 3 if n ≡ 1 (mod 3) Convergence of the above function can be studied via the termination of a corresponding rewriting system, although the translation is not as straightforward as the other generalized Collatz functions we have in this paper.Specifically, the mixed base scheme results in a compact rewriting system only when all the mappings an + b → cn + d applied by the generalized Collatz function at hand satisfy d < c.This is not the case for the function B above since it requires us to express 3n → 5n + 6 and 3n + 1 → 5n + 9.These mappings are expressed more easily by the help of unary representations, so we can have the following hybrid rewriting system BB over the alphabet {i, v, 0, , } to simulate the function B, where the new symbol v has the functional view v(x) = 5x.
We did not succeed in proving the termination of this rewriting system, which is not too surprising since the hybrid scheme does not even pass the test of proving the convergence of W .Alternatively, we can split the cases of B further for the congruence classes modulo 3 k with k > 1 until the iterated application of B can either be expressed as an + b → cn + d with d < c, or it reaches ⊥.After we perform this procedure while ensuring that the number of newly introduced cases are kept to a minimum, we end up with the following mappings to simulate B in an accelerated manner (similar to the idea in Section 4.4).Consider the symbols {0, 1, 2, v, w, x, y, z, , } with the following functional views.0(x) = 3x 1(x) = 3x + 1 2(x) = 3x + 2 v(x) = 5x w(x) = 5x + 1 x(x) = 5x + 2 y(x) = 5x + 3 z(x) = 5x + 4 (x) = 0 (x) = x With these symbols, we have the following mixed {3, 5}-ary (ternary-quinary) system BB the termination of which is equivalent to the convergence of B. The dynamic rules on the left implement the mappings from (11) and the rest are auxiliary rules that push ternary symbols towards the rightmost end of the string while preserving its value.We were unable to prove the termination of this system, so we include it as yet another challenge for automated termination proving.Erdős [Erd79] asked: When does the ternary expansion of 2 n omit the digit 2? This is the case for 2 0 = (1) 3 , 2 2 = (11) 3 , and 2 8 = (100111) 3 .He conjectured that it does not happen for n > 8.This conjecture can be reformulated as the statement that the following rewriting system E, where ← − X = {r → | → r ∈ X }, is terminating on all initial strings of the form f 8 f + .

9n
Given a string that corresponds to the binary representation of a power of 2, the inverted system ← − X essentially rewrites the string into ternary by pushing ternary symbols to the right without altering the value that the string represents.The two rules {0 → , 1 → } remove the occurrences of the ternary digits 0 and 1 (but not 2).If the ternary expansion does not contain the digit 2 then all digits will be removed, resulting in the string that can then be rewritten to itself indefinitely.This problem, as described, is an instance of "local termination" [WdE10] since it is concerned with termination on not all possible strings but a subset of them.We have not performed experiments with this system or local termination yet and we leave this for future work.

3
Termination is in fact equivalent to the existence of such interpretations [Zan94, Proposition 1].
(β n b • β m c )(x) = bcx + bm + n equivalently as another composition (β m c • β n b )(x) = cbx + cn + m for some suitable 0 ≤ n < b and 0 ≤ m < c.This allows us to swap the bases of adjacent positions while preserving the value of the string.

Claim 1 .
For any pair N, N of strings, if N → X N then Val(N ) = Val(N ), and if N → D T N then Val(N ) = T (Val(N )).Claim 2. For any string N with Val(N ) = 1, there exists no string N satisfying N → T N .Claim 3.For any integer ν > 1 and any string N with Val(N ) = ν, there exists a string N such that N → * T N and Val(N ) = T (ν).Proof of Claim 1. Assume N → X N .Then there exist strings X, Y and some rule → r ∈ X such that N = X Y and N = XrY .Recalling the definition of Γ from (7), we have Val(N ) = Val(N ) if and only if 8

Figure 1 :
Figure 1: Transition graphs of the iterates in the Collatz trajectories across residue classes modulo 8 for the functions C (left), T (middle), S (right).For each function f , the edge u → v is part of its transition graph if and only if there exists some n ≡ u (mod 8) such that f (n) ≡ v (mod 8).Bold edges indicate transitions where f (n) > n.


It is straightforward to see that the SRS C Even/4 = D Even/4 C ∪ X simulates the function C and the SRS T Odd/4 = D Odd/4 T ∪ X simulates the function T .The first two rules of D Even/4 C express the application of C to numbers of the form 4n and 4n + 2. Similarly, the last two rules of D Odd/4 T express the application of T to numbers of the form 4n + 1 and 4n + 3. Observing that a T -trajectory contains the same odd numbers as the corresponding C-trajectory, we have the following equivalences.Proposition 4.8.
Expansions of 2 n The Syracuse function maps each odd number to the next odd number in its Collatz trajectory.
function T with the same overall dynamics as C. Taking this idea further by performing as many divisions by 2 as possible leads to the so-called Syracuse function Syr : 2N + 1 → 2N + 1, k , where k = max{k ∈ N + | 2 k divides 3n + 1}.
and only if there exists a nonconvergent C-trajectory that avoids the residue classes of 5 and 7 (mod 8).Moreover, H as defined in (10) is convergent if and only if G is convergent, because the bijection n → (n − 1)/8 maps a G-trajectory to an H-trajectory.