aa r X i v : . [ c s . D M ] F e b Faulty picture-hanging improved
Johan W¨astlundFebruary 2, 2021
Abstract
A picture-hanging puzzle is the task of hanging a framed picturewith a wire around a set of nails in such a way that it can remainhanging on certain specified sets of nails, but will fall if any more areremoved. The classical brain teaser asks us to hang a picture on twonails in such a way that it falls when any one is detached.Demaine et al (2012) proved that all reasonable puzzles of thiskind are solvable, and that for the k -out-of- n problem, the size of asolution can be bounded by a polynomial in n . We give simplifiedproofs of these facts, for the latter leading to a reasonable exponentin the polynomial bound. A now famous picture-hanging puzzle was posed by A. Spivak in 1997. In [8](see also [7]), a “brain teaser” asked for an explanation of the following: Apicture hangs on two nails, and the wire is wound around the nails in such away that the picture will fall if any one of them is removed. One solution isshown in Figure 1. The puzzle has been popularized by several authors andvideo channels [5, 6, 9, 11].A more detailed account of the history of the puzzle is found in [2], whichalso discusses a connection to the Borromean rings. As was observed by NeilFitzgerald [7], the solution is a manifestation of the fact that the fundamentalgroup of the plane minus two points is non-abelian.If we choose a base-point, say where the picture is attached to the wire,and take the directed closed curves x and y as generators of the fundamental1igure 1: A solution to Spivak’s picture-hanging puzzle. The black dotsrepresent the nails. If any one of them is removed, it becomes apparent thatthe wire doesn’t actually wind around the other, and the picture falls.group as in Figure 2, then the picture-hanging of Figure 1 can be describedby the word xy − x − y. Equally valid solutions are obtained by xyx − y − etc. Since x and y don’tcommute, these words represent nontrivial group elements. But if either x or y is set to 1 (“quotiented out”), the whole expression will collapse to theidentity. The operation of setting x or y equal to 1 corresponds to removingone of the nails so that the curve around that nail becomes contractible.Once we have a group-theoretic version of the puzzle, we can prove theobvious generalization to n nails. This was noted by Fitzgerald, Chris LusbyTaylor and others. Again we refer to [2] for the background. Theorem 1.
For every n , it’s possible to hang a picture on n nails so thatit falls on the removal of any one of them.Proof. For n nails let the generators of the fundamental group be x , . . . , x n ,where x i is given by looping clockwise around the i :th nail only. Invokinginduction, let the word A be a solution for k nails x , . . . , x k for a suit-ably chosen k < n , and let B be a solution for the remaining n − k nails x k +1 , . . . , x n . Now take a commutator like ABA − B − and substitute the x i .Since the expressions we substitute for A and B are based on disjoint sets ofgenerators, no cancellations can take place as it stands. But if any one of thegenerators x , . . . , x n is set to 1, one of A and B will collapse to the identity,and so will the commutator. 2 y Figure 2: A pair of generators for the fundamental group of the plane minustwo points. Since the group is non-abelian, an expression like xy − x − y cannot be simplified to the identity.By taking k ≈ n/
2, this divide-and-conquer approach gives a solutionto the n nails puzzle that corresponds to a word of length about n in thefundamental group. Actually the length will be exactly n whenever n is apower of 2, with linear interpolation between the powers of 2. For instance,when n = 4 , , , , , , , ,
64. The questionwhether this is the minimal length of a nontrivial word that collapses onsetting any one of the generators to 1 is mentioned in [2] and seems to be anopen problem. A nontrivial lower bound was obtained in [3].As a side-remark, the case n = 3 is related to another puzzle named Curveand Three Shadows in [11]. The solutions found by John Terrell Rickard andDonald Knuth encode picture-hangings on three nails that will fall on theremoval of any one of them, but in that puzzle, even more was required.Notice that the fundamental group consists of equivalence classes of curvesunder homotopy, meaning that the curve is allowed to pass through itself (justnot through the nails). Therefore in order to get from a word like x x x − x − x x x − x − x x x − x − x x x − x − (1)(for n = 4) to a solution to the picture-hanging puzzle with a physical wire3hat cannot pass through itself, we must be careful to make sure that thepicture actually falls when a nail is removed. A construction by MichaelPaterson depicted in [2] shows a more efficient solution relying on the fact thata physical wire can lock itself even though its path corresponds to the identityelement of the fundamental group. We return to this issue in Section 3. The group-theoretic setting allows us to investigate picture-hanging puzzlesmore generally. For instance, the word xyzx − y − z − shows that we canhang a picture on three nails so that it stays on the removal of any one nail,but falls on the removal of any two.Considering other variations like the puzzles listed in [2], we are led tothe conjecture that all reasonable tasks of this kind are solvable, and this isindeed the case, as was shown in [2]. Here we present two slightly differentproofs that are simpler than the one given in [2].In order to make precise the concept of a reasonable picture-hangingpuzzle, we can encode a given task for n nails as a boolean function of n variables. Although it’s not important, we prefer a convention opposite tothe one in [2], and take the i :th input variable to be true if the i :th nailis present, and false if it’s removed. Consequently the output is true if thepicture remains hanging, and – homophonic mnemonic – false if it falls.If S is a set of generators/nails, we can denote by Λ( S ) a generic non-trivial word with the property (as in Theorem 1) of collapsing to the identitywhenever one of the generators in S is set to 1. Here the letter Λ is meantto resemble the symbol V that stands for logical AND.Not all boolean functions can be realized as picture-hangings. For in-stance we can’t ask the picture to hang if we remove all nails. It also seemsthat the function must be monotone: If the picture hangs on a certain setof nails, it can’t fall because more nails are present. Topologically, a nailonly restricts the movement of the wire and cannot allow it to untangle if itcouldn’t otherwise. And in the group theoretical setting, if a word simplifiesto the identity, it can’t evaluate to something else because more generatorsare set equal to 1. We return briefly in Section 3 to the question whethermonotonicity is actually necessary in a physical model. Theorem 2.
Every nontrivial monotone boolean function can be realized asa picture-hanging. irst proof of Theorem 2. For a given nontrivial monotone boolean function f , let S , . . . , S N be the minimal sets where f evaluates to true , in other wordsthe minimal sets of nails where the picture is supposed to keep hanging. Weclaim that the word Λ( S ) · Λ( S ) · · · Λ( S N ) (2)represents the function f .In one direction it’s clear: If we quotient out enough generators that noneof the sets S i remains intact, then (2) collapses to the identity, as it should.On the other hand it might not be obvious that (2) can’t also collapseif enough generators remain that several factors are nontrivial. However, ifthe set of remaining generators/nails is equal to one of the sets S i , then byminimality only the factor Λ( S i ) is nontrivial, and the whole expression (2)evaluates to that factor. Finally we already know that monotonicity holds:The expression (2) can’t become the identity because more than a minimalset of generators remain.Our second proof is based on emulating logical AND- and OR-gates, asin the proof in [2].If A and B are words, the new word ABA − B − might collapse even ifboth A and B are distinct from the identity: The equation ABA − B − = 1is equivalent to AB = BA , which means that ABA − B − collapses preciselywhen A and B commute. This can happen in some ways that aren’t com-pletely trivial, for instance if A = xyx − and B = xy x − . For this reasonwe can’t always use the commutator ABA − B − as an AND-gate: Whileit’s true that the commutator becomes the identity unless both A and B arenontrivial, the converse is not true.Similarly, AB may collapse even if A = 1 and B = 1, simply by A and B being inverses. Therefore we cannot always use the product of two words asan OR-gate.Demaine et al [2] show how to construct “safe” logical gates by applyingtheorems of A. I. Mal’tsev and G. A. Gurevich. Here we point out that asimplification is possible. In order to obtain a safe OR-gate, we take twoarbitrary generators x and y (we must assume that the number of genera-tors/nails is at least 2), and pad the words A and B by surrounding them bythe symbols x , y and their inverses in the following way:( x M Ax − M ) · ( y M By − M ) . (3)5gain it’s clear that if A = B = 1, then (3) will collapse to 1 as well.Moreover, if one of A and B is nontrivial and the other is 1, then (3) willbe nontrivial. In the final case that A and B are both nontrivial, we claimthat provided M is large enough, (3) can’t collapse. This is based on thefollowing easy lemma: Lemma 3.
If the symbols x and x − both occur fewer than M times in theword A = 1 , then x M Ax − M will simplify to a word that both begins and ends with one of the symbols x or x − .Proof. If A is a nontrivial power of x , then so is the simplified word. Other-wise there is some symbol other than x and x − that remains after simplifying A . In that case no symbol from the left padding will cancel against any sym-bol of the right padding. Since every cancellation will use up one symbol from A and at most one from the padding, this means that at least one symbolwill remain from each side of the padding.In the same way we can construct a safe AND-gate by starting from theexpression ABA − B − and pad to avoid unwanted cancellations:( x M Ax − M ) · ( y M By − M ) · ( x M A − x − M ) · ( y M B − y − M ) . (4)Again provided x and x − occur fewer than M times in A , and y and y − occur fewer than M times in B , the expression (4) can’t collapse unless oneof A and B does. We thereby obtain a second proof: Second proof of Theorem 2.
It’s a fact of basic propositional logic that thenontrivial monotone boolean functions are precisely those that can be ex-pressed by nesting AND- and OR-gates. An expression in terms of suchgates can be translated to the required word in the free group by repeatedlyapplying (3) and (4).
In order to argue that Theorem 2 is the end of the story as far as solvabilityof picture-hanging puzzles goes, it seems we have to exclude some physics.6
B AB C
Figure 3: Left: A counterexample to monotonicity. If we hold the pictureand wire in this position and let go, the nail A will slow the picture downenough that everything falls. But if the nail A hadn’t been there, the picturewould have fallen straight through the loop and become stuck around B .Right: The condition for the picture to remain hanging might not even be afunction of the set of remaining nails. If we remove nail A , the picture willfall through the loop below it. If we then remove nail C , the picture willstill be attached around nail B . If on the other hand we first remove C , thepicture already falls (and remains fallen if we then remove nail A ).With a wire that can’t pass through itself and a finite gravitational field, wecould solve even some non-monotone puzzles.Figure 3 (left) shows a situation where the picture would fall if we letgo, while it would have remained hanging if the nail A hadn’t been there.This example might seem contrived, as we normally think of the picture ashanging in equilibrium and the nails being removed one by one.But then it’s even worse: The condition for the picture to remain hangingmight not even be a function of the set of remaining nails, but could dependon the order in which they are removed. To see this, we just modify theprevious example using a third nail C as in Figure 3 (right).These examples obviously depend on a number of assumptions about theexact positioning of the nails and the wire, friction, gravity, and so on. Herewe simply conclude that this is too complicated, and in the following weconsider the group-theoretical model only.That said, it would obviously be interesting to have an improvement ofthe results of the following section in the spirit of the Paterson solution [2]to the original n -nails puzzle. 7 The k -out-of- n puzzle As was pointed out by Demaine et al [2], the sheer number of monotoneboolean functions on n variables (the so-called Dedekind number) impliesthat most of them will require almost 2 n symbols for a representation as aword in the free group. In this perspective, the so-called k -out-of- n problem,where the picture should remain hanging if and only if at least k out of n nails remain, turns out to admit an unusually efficient representation.In [2], a construction based on a sorting network shows that k -out-of- n has a representation of length O ( n , , ). The exponent can be improvedby simplifying the logical gates as in Section 2, but it will still be in thethousands as long as it relies on sorting networks of the AKS-type. Here weestablish a polynomial bound with a reasonable exponent, although we don’thave an efficient method of computing what that representation looks like. Divide-and-conquer
We first mention a divide-and-conquer solution that achieves a representationof “quasi-polynomial” length n O (log n ) . This is already shorter than “most”monotone boolean functions. Conceivably the method can be improved, butit doesn’t quite seem to give a polynomial bound.Suppose we have 2 n generators x , . . . , x n . Inductively let A k be a repre-sentation of at least k out of x , . . . , x n , and similarly let B k represent at least k out of x n +1 , . . . , x n (if k > n , then A k = B k = 1). Now we can represent k out of 2 n by B k · ( A B k − A − B − k − ) · ( A B k − A − B − k − ) · · · ( A k − B A − k − B − ) · A k . (5)If fewer than k generators remain, (5) will collapse, while if exactly k remain,then exactly one of the factors will be nontrivial. We don’t need any paddingto make each factor safe, since A i and B k − i involve disjoint sets of generators.An inductive argument shows that if n is a power of 2, say n = 2 a , thenthe length of the word representing k -out-of- n will be at most2 a ( a +3) / = n ( a +3) / = n log n +3 / . This bound can be improved slightly, but we don’t seem to get a polynomialbound on the length of the word in this way.8 probabilistic approach
Using instead a probabilistic method, we show that for arbitrary k and n with 1 ≤ k ≤ n , there exists a word of length O ( n . ) in the generators x , . . . , x n that remains nontrivial if all but k generators are set to 1, butcollapses if only k − Theorem 4.
For n and k with ≤ k ≤ n , the k -out-of- n function can berepresented as a picture-hanging by a word of length O ( n c ) , where c = log / (6) + log (6) ≈ . . (6) The case n = 2 k − We first establish the special case of n = 2 k −
1, where n is odd and thepicture is required to hang precisely when a majority of the nails remain.Then we show how to modify the argument for the case of general k .We construct recursively a sequence W , W , W , . . . of random words inthe generators x , . . . , x n that will eventually tend to have high probabilityof evaluating to something nontrivial if k of the generators remain, and tothe identity if only k − k − k nailsrespectively. Therefore we let φ i be the homomorphism of the free groupgenerated by x , . . . , x n to itself given by mapping x , . . . , x i to themselves,and all the following generators to 1. Since the following construction of W , W , W , . . . will be symmetric under all permutations of the generators,it suffices to analyze the probabilities that φ k − ( W d ) = 1 and that φ k ( W d ) = 1respectively.The depth zero word W is just a single symbol uniformly chosen fromthe n symbols x , . . . , x n . Clearly the probability that W “hangs” on thefirst i nails is given by P ( φ i ( W ) = 1) = in . We would like it to hang on the first k nails but not on the first k −
1, sowe can say that the probability p of “failure” is the same in both directions: p = P ( φ k − ( W ) = 1) = P ( φ k ( W ) = 1) = 12 − n .
9o build recursively the random depth d + 1 word W d +1 , we combinethree independently chosen words of depth d with a safe majority-gate . Thesafe majority gate is constructed from the expression ABCA − B − C − bypadding: x M Ax − M y M By − M z M Cz − M x M A − x − M y M B − y − M z M C − z − M . (7)As the depth d increases, the word W d will distinguish more and moreclearly between the cases of a majority or minority of generators remaining.We wish to bound the probability of failure, and therefore let p d = P ( φ k − ( W d ) = 1) = P ( φ k ( W d ) = 1) . Since W d +1 fails precisely when at least two out of three independent wordsof distribution W d fail, we have p d +1 = p d + 3 p d (1 − p d ) = 3 p d − p d . Next we want to show that p d approaches zero reasonably quickly. Weanalyze separately the first phase, where p d is close to 1 / / p d is close to zeroand is essentially squared in each step.When p d is close to 1 /
2, the distance to 1 / / Lemma 5. / − p d +1 p d +1 ≥ · / − p d p d . Proof.
We let p d = p and plug in p d +1 = 3 p − p . Then we are comparing1 / − p + 2 p p − p to 32 · / − pp . After clearing the denominators, we find that the difference2 p (1 / − p + 2 p ) − / − p )(3 p − p )factorizes as 2 p (2 − p )( p − / , which is nonnegative in the interval 0 ≤ p ≤ / / − p d p d ≥ / − p p · (cid:18) (cid:19) d ≥ n · (cid:18) (cid:19) d . This means in particular that if p d ≥ /
4, then (3 / d ≤ n . We concludethat in order to ensure that p d ≤ /
4, it suffices to go to depth d ≥ log / ( n ).After just one more step, the probability of failure will be smaller than1 /
6, and will then quickly approach zero, roughly squaring in each step:
Lemma 6. p d +1 ≤ (3 p d ) . Proof. · (3 p − p ) = 9 p − p ≤ p = (3 p ) . Therefore, if p a ≤ / p a ≤ /
2, then3 p a + b ≤ (1 / b . It follows that p d < − n for some d = log / ( n ) + log ( n ) + O (1) . (8)Since the construction of W d is symmetric in the generators x , . . . , x n ,the estimated failure probability holds for every possible state (present orremoved) of the set of nails. We conclude that for d as in (8), the probabilitythat W d fails on as much as a single one of the 2 n states of the nails is smallerthan 1. Therefore there has to be a word among the possibilities for W d thatdoesn’t fail on any of the states.Next we analyse the length of the word W d . If it wasn’t for the padding, W d would have length6 d = O (cid:0) log / ( n )+log ( n ) (cid:1) = O (cid:0) n log / (6)+log (6) (cid:1) in accordance with (6).It can be verified that the padding in total only increases the lengthby another constant factor: Before the words reach length 2 n , the padding11onsists of only one symbol at each end. In this phase, the length (1, 18, 120etc) of the word X d is exactly 17 · d − , and in particular only imposes an extra factor bounded by 17 /
5. Once thewords W d reach length 2 n (so that they might have one pair of inverses ofeach of the n generators), the contribution of the padding can be estimatedby a factor 1 + 2 /n in each step, which grows to a factor of 1 + O (log n/n )over the remaining O (log n ) steps.Notice here that we can choose the padding after the random choices ofgenerators in the words. General k Finally we establish Theorem 4 for general k . To do this, we modify the firststep of the construction by letting W be a product of a suitably chosen,possibly random, number m of symbols taken uniformly from x , . . . , x n andconditioned on being distinct. That is, given m , they are chosen with uniformdistribution on the (cid:0) nm (cid:1) sets of m generators. This product will act as an OR-gate, with nontrivial evaluation if and only if at least one of the generatorsin the word is not quotiented out.We still want the “failure probability” to be the same in both directions,that is, we want to choose m so that P ( φ k − ( W ) = 1) = P ( φ k ( W ) = 1) . This is not possible for a fixed value of m except in some special cases (like k = 3, n = 9, m = 2). But it can obviously be achieved if we choose m randomly, and we can let m have support on the two consecutive integerswhere P ( φ k − ( W ) = 1) overtakes P ( φ k ( W ) = 1). If k > n/ m will beeither 0 or 1 and the following analysis rather trivial, but the case k < n/ W : Relative to φ k − , the word W fails when the minimal indexis strictly smaller than k so that φ k − ( W ) = 1. On the other hand relative to φ k , it fails if the minimal index is strictly larger than k so that φ k ( W ) = 1.12ssuming that the two failure probabilities are equal, we get a lowerbound on the probability that the minimum index is equal to k : P (minimum index = k )= P ( x k occurs in W ) · P (remaining indices > k ) ≥ E ( m ) n · , since the probability that all indices are ≥ k is at least 1 / k . This gives a bound away from1 / p : p = 1 − P (minimum index = k )2 ≤ − E ( m )4 n . (9)Even for large k we have E ( m ) ≥ /
2. Therefore in the regime n/ ≤ k ≤ n it’s clear that the modified first step only affects the implied constantin Theorem 4.For small k , and thereby possibly large m , the modified first step imposesan extra factor of E ( m ) + O (1) on the length of the word W and therebyon all subsequent words. But by (9), it also gives an extra factor of order m in 1 / − p . This is better than what is provided by the initial phase ofthe majority function, where increasing 1 / − p d by a factor 3 / t increases the length of the word by t log / (6) .Therefore when m is large, the extra length of the word W will be morethan compensated for by fewer rounds of the majority function needed. Thecase of general k therefore gives, up to a constant factor, the same bound onthe length of the word as the case n = 2 k −
1. This concludes the proof ofTheorem 4.
Finding hay in a haystack
While rigorously demonstrating the existence of a polynomial-size word thatsolves the k -out-of- n -problem, our argument doesn’t provide an efficientrecipe for finding it.But the situation isn’t that bad: if we take the recursion involving themajority function just one more step than is needed in the proof of Theorem 4,the failure probability on random input will essentially drop to just 2 − n . This13eans that the probability that there is even a single state where the wordfails is now exponentially small. The computational problem therefore hasthe character of “finding hay in a haystack”. References [1] Ivan Bjerre Damg˚ard, Jonas K¨olker, Peter Bro Miltersen,
Secret Shar-ing and Secure Computing from Monotone Formulae , Cryptology ePrintArchive, Report 2012/536, (2012).[2] Erik D. Demaine, Martin L. Demaine, Yair N. Minsky, Joseph S. B.Mitchell, Ronald R. Rivest, Mihai Pˇatra¸scu,
Picture-Hanging Puzzles ,Theory of Computing Systems 54, 531–550 (2014).[3] Radoslav Fulek and Sergey Avvakumov,
A Note on a Picture-HangingPuzzle , arXiv:1812.06335 (2018).[4] Oded Goldreich,
Valiant’s Polynomial-Size Monotone Formula for Ma-jority , 2011.[5] Matt Parker, Things to Make and Do in the Fourth Dimension, PenguinBooks 2015.[6] Matt Parker (standupmaths), How to mathematically hang a picture(badly), YouTube.[7] Torsten Sillke, discussion thread. math.uni-bielefeld.de/~sillke/PUZZLES/quantum/B201 .[8] A. Spivak,
Strange Painting , Quantum (May/June 1997).[9] Jade Tan-Holmes (Up and Atom), How Knot To Hang A Painting,YouTube.[10] Leslie G. Valiant,