• Posted by Konstantin 28.10.2008 2 Comments

    The amusing fact that Minesweeper was proven to be NP-complete is quite well known in certain circles. However, it seems that no one has yet cared to publicly demonstrate the (probably obvious, but not a single bit less amusing) fact, that constructing LEGO toys is also an NP-complete task. Here I fix this disturbing flaw and present a reduction of SAT to LEGO by a simple example.

    Suppose you are given the following set of LEGO blocks

    LEGO Blocks

    and you wish to construct the following structure from them (using only this picture as a reference):

    It turns out that devising such a configuration is equivalent to finding a satisfying assignment for the boolean formula (A\vee\neg B)\wedge(\neg A \vee B), and it is possible to devise an analogous configuration for any other logical formula in CNF. Thus, building LEGO must be at least as hard as satisfying boolean formulas, that is, NP-hard.

    Indeed, let the red brick correspond to the variable A, the blue brick let be B, the pink brick \neg A and the light blue brick \neg B.
    Consider the part I of the target configuration (the one in the upper left). It contains one red brick and one light blue brick, but because of the black block in front of them we don't know whether the red and the light blue bricks are of height 1 or 2. There are three possible options:

    We say that this configuration corresponds to the term A\vee \neg B, where having a higher brick for a given variable corresponds to setting the value of that variable to True. Clearly, for the configuration to be possible either the red brick (A) or the light blue brick (\neg B) must be high, and therefore a proper choice of bricks here corresponds to a choice of values in the expression A\vee \neg B. Analogously, part II corresponds to the term \neg A\vee B and the fact that both parts are possible translates to the full equation (A\vee\neg B)\wedge(\neg A \vee B).

    Now what about parts III and IV? These guarantee that if we choose the high red brick when constructing parts I and II, we shall necessarily have to use the shorter pink brick there, and similarly for the blue and light blue bricks. Indeed, due to the choice of white bricks there are two ways of constructing part III:

    In the first case we use up the high red brick and the short pink brick for constructing part III, and therefore end up with the short red brick and high pink brick for building parts I and II. This corresponds to picking the value False for A. Similarly, the second way of constructing part III would enforce the value True for the variable A.

    A short reflection should convince you now, that the same scheme can be used to represent any other CNF boolean expression. As it is well known that finding a satisfying assignment for a boolean formula is NP-complete, it follows that LEGO is NP-complete too.


    Tags: , ,