Quadratic sync problem

From Esolang
Jump to navigation Jump to search

The quadratic sync problem is a problem designed by User:ais523 to be hard (possibly impossible) to solve efficiently, but easy to implement a brute-forcer for in even very simple programming languages. As such, it serves as a template for writing small programs in low-level languages whose halting behaviour is hard to predict.

Definition

A quadratic sync problem is a quintet of non-negative integers a, b, c, d, e.

A solution to a quadratic sync problem is a pair of non-negative integers x, y, such that ax2+bx+c=dy2+ey.

Difficulty

The wikipedia:Quadratic residuosity problem, which can be expressed as bx+c=y2, is an example of a quadratic sync problem; specifically a quadratic sync problem with a=0, d=1, e=0. The quadratic residuosity problem has no known efficient solutions (i.e. the known solutions to it have a comparable time complexity to just brute-forcing possible values of x and y). That implies that the quadratic sync problem is unlikely to be efficiently solveable either.

Implementation

The sequence of possible values a×02+b×0+c a×12+b×1+c, a×22+b×2+c, a×32+b×3+c, etc. of the left hand side of a quadratic sync problem is just the cumulative sum of an arithmetic series (specifically, you start at c, then add b+1a, b+3a, b+5a, etc., i.e. the amount added is initially equal to a+b and increases by an additional 2a with each element). A similar principle applies to the right hand side. Thus, the problem collapses to the question of whether two sequences, each of which it's individually easy to generate, have any elements in common.

Because both sequences are strictly increasing sequences of integers, there are at least two simple (but inefficient) algorithms to brute-force solutions. One is to start with x=y=0 and repeatedly add 1 to x if the LHS is smaller, or y if the RHS is smaller, until the two sides are equal. The other is to try possible solutions one at a time from 0 upwards, constantly remembering how far it is to the next possible value of the LHS and of the RHS, and decreasing those values by 1 at each iteration (updating them whenever one side hits 0 but not the other); the advantage of this method is that x and y don't need to be directly stored anywhere (although if a and d are nonzero, they'll be stored indirectly, via the sizes of the gaps between possible LHS values and possible RHS values respectively). This makes the quadratic sync problem easy to implement in low-level and esoteric languages.

Computational class

The ability to encode the quadratic residuosity problem into the quadratic sync problem implies that the latter is at least as hard. Because it can potentially use unbounded values, it may well be harder; although ais523 would be mildly surprised if the problem turned out to be Turing-complete (more precisely, complete for recursively enumerable problems), there is no obvious reason why it can't be. It's therefore possible to view the problem as a language in its own right (that's either zero-dimensional or two-dimensional based on your point of view), rather than a problem to implement in other languages.