2

Consider the set of all bit arrays of length n. Now consider the set of all 1-to-1 functions that map from this set to this set.

Now select a single function out of the latter set. Is there any algorithm to find a "minimal" method of implementing this function? Assume that we only have access to fundamental bit array operators such as AND OR XOR NOT and left and right bitshifts.

In case you're wondering, the reason I want this is because I'm writing an algorithm to convert from z-curve ordering of bits to hilbert-curve ordering of bits. My current method is to make a lookup table, but I bet there's a better option.

As a simple example, let's say I have a truth table that looks like this:

00 -> 10
01 -> 01
10 -> 00
11 -> 11

Then I should be able to infer that, given an input bit string input, the output bit string output is (in java syntax)

output = ((~input) << 1) ^ input

Here's the proof in this case:

00 -> 11 -> 10 -> 10
01 -> 10 -> 00 -> 01
10 -> 01 -> 10 -> 00
11 -> 00 -> 00 -> 11
JnBrymn
  • 24,245
  • 28
  • 105
  • 147
  • If you manage that, make sure you short-sell a lot of RSA shares before publishing. You will have created a contructive formula for prime numbers. – Eugen Rieck May 14 '13 at 00:01
  • Ha! So I guess you're saying this is a HardProblem™ Do you have any links I can read? Do you have any other rationale for your statement? (Feel free to supply it as an answer.) – JnBrymn May 14 '13 at 01:03
  • @JohnBerryman though cross-posting is discouraged, I wonder if you'd find a more satisfactory answer on Math SE – Doug T. May 14 '13 at 02:27
  • 1
    You mean like [this question here](http://math.stackexchange.com/questions/389083/inferring-simplest-method-to-convert-bit-array-1-to-bit-array-2) to which one user encouraged me to post to SO? Amusingly, that person assured me that a standard algorithm probably exists. (Cf. @Eugen Rieck's comment.) I also posted to the [Theoretical Computer Science SE](http://cstheory.stackexchange.com/questions/17615/inferring-simplest-method-to-convert-bit-array-1-to-bit-array-2) but those guys usually make fun of my questions. – JnBrymn May 14 '13 at 02:32
  • This may be reducible from [CIRCUIT-SAT](http://en.wikipedia.org/wiki/Circuit_satisfiability_problem), and if so would be [NP-Complete](http://en.wikipedia.org/wiki/NP-complete) – recursion.ninja Oct 13 '13 at 19:56

0 Answers0