Pairwise addition

Pairwise addition is an esoteric rewriting rule for natural numbers invented by User:Hakerh400 around 2006 and published in 2022.
== Definition ==
We specify rewriting function f in the following way. Given natural number n (non-negative integer). If n\le9, then f(n)=n. Otherwise, f(n) is equal to the concatenated results of adding each two consecutive digits of n in base 10.
We say that a number is trivial iff it is of the form d_1\cdot10^k+d_2, where d_1 and d_2 are decimal digits and k is a natural number.
We say that a number is simple iff it contains two consecutive zeros.
== Examples ==
For example, we start with number 1990. Consecutive digits are 19, 99 and 90. The sums are 10, 18 and 9, so the next number is 10189. We apply the same rules: 1+0=1, 0+1=1, 1+8=9, 8+9=17, so the next number is 11917. We can continue, until we reach a single-digit number:
 1990
 10189
 11917
 210108
 31118
 4229
 6411
 1052
 157
 612
 73
 10
 1
We say that 1990 reduces to digit 1. There are numbers that do not terminate, i.e. never reach a digit. The smallest non-terminating number is 991:
 991
 1810
 991
 ...
After two steps, it reduces to itself. If we reverse the number, it terminates and reduces to digit 4:
 199
 1018
 119
 210
 31
 4
There are numbers that do not terminate, but do not create a cycle:
 9999
 181818
 99999
 18181818
 9999999
 ...
== Properties ==
If m concatenated with n terminates for some numbers m and n, then both m and n terminate. (proof omitted)
If some n does not terminate, then any number m containing n in its decimal expansion also does not terminate. (proof omitted)
The smallest non-terminating number is 991. (proof omitted)
If an n-digit number terminates, where n\ge7, then that number contains 0 in its decimal expansion. (proof omitted)
A number terminates iff in the sequence there is no number whose decimal expansion contains one of the following patterns:
* two 9s, followed by digit d\ge1
* three 6s, followed by digit d\ge4
* four 8s
(proof omitted)
Any trivial number terminates. (proof omitted)
The longest terminating sequence for a non-simple number is 37. (proof omitted)
The largest non-trivial terminating number is 11000000000000008. (proof omitted)
== Notable numbers ==
Number 221027 produces a sequence of length 37. It is the longest sequence for a non-simple number.
 221027
 43129
 74311
 11742
 28116
 10927
 19119
 1010210
 111231
 22354
 4589
 91317
 10448
 14812
 51293
 631112
 94223
 13645
 49109
 131019
 441110
 85221
 13743
 410117
 51128
 62310
 8541
 1395
 41214
 5335
 868
 1414
 555
 1010
 111
 22
 4
The largest non-trivial terminating number:
 11000000000000008
 2100000000000008
 310000000000008
 41000000000008
 5100000000008
 610000000008
 71000000008
 8100000008
 910000008
 101000008
 11100008
 2210008
 431008
 74108
 11518
 2669
 81215
 9336
 1269
 3815
 1196
 21015
 3116
 427
 69
 15
 6
== Implementation ==
Implementation in Haskell:
<nowiki>
type N = Integer
infixr 0 #
(#) = id
n :: N
n = 1234
digits :: N -> [N]
digits = map (read . pure) . show
f :: N -> N -> [N]
f a b = digits # a + b
step :: [N] -> [N]
step xs = concat # zipWith f xs # tail xs
run :: [N] -> [[N]]
run xs = xs : if length xs == 1 then [] else run # step xs
main :: IO ()
main = mapM_ (putStrLn . (>>= show)) # run # digits n
</nowiki>