Predict the number pattern of given sequence

I am curious if it is possible to do so. For example,

If I supply [0,1,2,3,4,5] the model should return natural number sequence

[1,3,5,7,9,11] should return natural number with step of 2

[1,1,2,3,5] should return Fibonacci Number

[1,4,9,16,25] should return Square natural number

and so on.

Those all fit into a single quadratic, auto-correlated model.

$$x_0 = a \\ x_i = b i^2 + c x_{i-1} + d i + e$$

The sequences can be curve fitted producing a set of $$n$$ perfect fits of the form $$(a, b, c, d, e)$$ given the above model. A rules engine given the correct parameterized rules can produce the most desirable verbal description from among the $$n$$ fits in the set. The rules can also be prioritized by a simple feed forward network trained to simulate the most natural selection of string descriptions from any set of fits where $$n > 1$$.

This will work well for the examples in the question and many more, however, if the sequence $$\{1, 4, 1, 5, 9\}$$ is fed into the system, it will produce some weird description based on the quadratic, auto-correlated model it was given rather than, "digits of $$\pi$$ to the right of the decimal place."

The only way to produce the most common response a university freshman math student would produce would be to extend the boundaries of AI engineering first. For example, once an AI system is developed that can handle natural language and cognition like a child, several of them can be separately trained in a simulation of primary and secondary school mathematics. The median response for each sequence given to the class of AI students (class made up of artificial students studying math, not class of humans studying AI) will then be a reasonable prediction of what human university freshmen would produce as a median response.

This can be framed as a classification problem where a model is supervised on a dataset containing finite-length number sequences $$x^{(i)}_1, \cdots, x^{(i)}_n$$ and the sequence name $$y_i$$. For example, the dataset could look like this:

• ([0,1,2,3,4], 0)
• ([1,3,5,7,9], 1)
• ([1,1,2,3,5], 2)
• ([1,4,9,16,25], 3)

where the numbers on the right are integer representations of the sequence name. Given intuitive sequences, plentiful training data, and training examples of reasonable length, this problem would not be that difficult to solve. Sequence models from deep learning, such as recurrent networks (LSTM, GRU) or temporal convolutional networks, are well-suited for tasks such as this one.

Of course, this is only possible within certain constraints. The models are only good at what they are trained to do, so it would be impossible to use them to infer whether a sequence skips by 2 or 3 without having that information explicitly present in the training data. It would be interesting to see whether unsupervised models could detect this sort of information, although I don't think this work has been done in the present.