by mythamatics · 3y ago · 0 comments
Here is the non-branching form:
0. Start with an odd number n
1. Apply n = 3n + 1
2. Count trailing zeroes of n
3. Right shift n by the trailing zero count
4. Return to (1), stopping at n = 1
I mean, lambda calculus doesn't have any build-in branching, but you can style write arbitrary programs in it. Same for 'post correspondence problem' or SKI calculus.
All of these can be defined as "branching" or "non-branching" however you want.
f = lambda n: (n & 1) * n + ((n + 1) >> 1)
No need to count any trailing zeros.Of course, the multiplication sort-of acts as a branch.
If you're trying to feed a SAT solver, you can bound the size of the numbers at some level, and then pass one of the closed-form formulas into the solver.