Learning Recursive Sequences via Evolution of Machine-Language Programs

We use directed search techniques in the space of computer programs to learn recursive sequences of positive integers. Specifically, the integer sequences of squares, x; cubes, x; factorial, x!; and Fibonacci numbers are studied. Given a small nite pre x of a sequence, we show that three directed searches|machine-language genetic programming with crossover, exhaustive iterative hill climbing, and a hybrid (crossover and hill climbing)|can automatically discover programs that exactly reproduce the nite target pre x and, moreover, that correctly produce the remaining sequence up to the underlying machine's precision. Our machine-language representation is generic|it contains instructions for arithmetic, register manipulation and comparison, and control ow. We also introduce an output instruction that allows variablelength sequences as result values. Importantly, this representation does not contain recursive operators; recursion, when needed, is automatically synthesized from primitive instructions. For a xed set of search parameters (e.g., instruction set, program size, tness criteria), we compare the e ciencies of the three directed search techniques on the four sequence problems. For this parameter set, an evolutionary-based search always outperforms exhaustive hill climbing as well as undirected random search. Since only the pre x of the target sequence is variable in our experiments, we posit that this approach to sequence induction is potentially quite general.