My solution to “Tree-edge Triage”

Back in September, I found out about the puzzle “Tree-edge Triage”.

The problem asks us to consider an infinite binary tree with edges labeled “A” and “B”. The choice is made randomly and independently for each edge, with the probability of an “A” label being denoted by pp.

An infinite binary tree, with edges labeled “A” and “B”. A single path is traced from the root.

An adversarial game is then played on this tree by two players, Alex and Beth. Starting with Alex, they take turns stepping downward from the root. Beth wins if she can ever force an edge labeled by “B” to be crossed. Conversely, Alex wins if he can continue play forever with both players only crossing “A” edges. (The image depicts a winning game for Beth.)

We are interested in the circumstances under which Alex has a nonzero probability of winning, assuming perfect play for both players. Observe that for 0<p<10 < p < 1, he cannot be guaranteed a win, since there is a nonzero probability that the first two edges in the tree are labeled “B”, forcing him to make a losing move.

The question posed by the puzzle is to determine the infimum of the set of values of pp for which Alex has a nonzero probability of winning. In other words, we are interested in the boundary between the values of pp that are almost surely a win for Beth, and the values for which Alex has a nonzero chance to win, regardless of how the boundary value itself is classified.

In notation, we want:

q=inf{p|0p1P[Win(τ)τTreesp]>0} q = \inf \left\{ p \,\middle|\, \begin{split} & 0 \le p \le 1 \\ & \mathbb{P} [ \text{Win}(\tau) \mid \tau \sim \text{Trees}_p ] > 0 \\ \end{split} \right\}

where τ\tau is a tree, Win(τ)\text{Win}(\tau) is the proposition that the tree τ\tau is winnable by Alex playing first, and Treesp\text{Trees}_p is a random variable ranging over infinite binary trees where the probability of an “A” label is pp.

This concludes my description of the problem. If you want to work on it yourself, and to avoid spoilers, stop here.



A warm-up — hopelessness

I’ll use variables like A,B\ell \in { \text{A}, \text{B} } to range over labels and adopt a 2D notation for trees:

τ::=(12τ1τ2)=((1,τ1)(2,τ2))(alternative notation) \begin{aligned} \tau & ::= \left( \begin{array}{c} \bigcirc \\ {\scriptstyle \ell_1} \swarrow \quad \searrow {\scriptstyle \ell_2} \\ \tau_1 \quad \quad \quad \tau_2 \\ \end{array} \right) = \left( \begin{array}{c} \bigcirc \\ {\scriptstyle (\ell_1, \tau_1)} \quad {\scriptstyle (\ell_2, \tau_2)} \\ \end{array} \right) & \text{(alternative notation)} \end{aligned}

Intuitively, Beth has an easier job than Alex — she only needs to get lucky once, while her opponent needs to get lucky every time. My expectation going in was that we should expect qq to be close to 1. The other people I talked to about the problem felt the same way.

In fact, we can relax the problem a bit to get a lower bound on qq — some trees τ\tau have the property that Alex will lose even with Beth’s cooperation. This occurs if there are no paths down from the root that don’t eventually pass through a B edge. We can denote this condition by Hopeless(τ)\text{Hopeless}(\tau) and define it (co)recursively:

Hopeless(12τ1τ2)...((1=B)Hopeless(τ1))((2=B)Hopeless(τ2)) \text{Hopeless}\left( \begin{array}{c} \bigcirc \\ {\scriptstyle \ell_1} \swarrow \quad \searrow {\scriptstyle \ell_2} \\ \tau_1 \quad \quad \quad \tau_2 \\ \end{array} \right) \triangleq \begin{split} & \phantom{...} \\ & ((\ell_1 = \text{B}) \lor \text{Hopeless}(\tau_1)) \, \land \\ & ((\ell_2 = \text{B}) \lor \text{Hopeless}(\tau_2)) \end{split}

or, rephrasing in terms of predicates on (,τ)(\ell, \tau) pairs (which we’ll call branches):

{Hopeless((1,τ1)(2,τ2))H(1,τ1)H(2,τ2)H(,τ)(=B)Hopeless(τ) \left\{ \begin{aligned} \text{Hopeless} \left( \begin{array}{c} \bigcirc \\ {\scriptstyle (\ell_1, \tau_1)} \quad {\scriptstyle (\ell_2, \tau_2)} \\ \end{array} \right) & \triangleq \text{H}(\ell_1, \tau_1) \land \text{H}(\ell_2, \tau_2) \\ \text{H}(\ell, \tau) & \triangleq (\ell = \text{B}) \lor \text{Hopeless}(\tau) \end{aligned} \right.

For any tree, the hopelessnesses of its branches are independent from each other; for any branch, its choice of child is independent from its choice of subtree. This means we can turn these equations into equations about probabilities:

sP[Hopeless(τ)]=P[H(1,τ1)H(2,τ2)]=P[H(,τ)]2P[H(,τ)]=P[(=B)Hopeless(τ)]=1P[=A]P[¬Hopeless(τ)]=1p(1s) \begin{aligned} s \triangleq \mathbb{P} [ \text{Hopeless}(\tau) ] & = \mathbb{P} [ \text{H}(\ell_1, \tau_1) \land \text{H}(\ell_2, \tau_2) ] \\ & = \mathbb{P} [ \text{H}(\ell, \tau) ]^2 \\ \mathbb{P} [ \text{H}(\ell, \tau) ] & = \mathbb{P} [ (\ell = \text{B}) \lor \text{Hopeless}(\tau) ] \\ & = 1 - \mathbb{P} [ \ell = \text{A} ] \mathbb{P} [ \neg \text{Hopeless}(\tau) ] \\ & = 1 - p (1 - s) \end{aligned}

To which the solution is:

s=(11p)2 \begin{aligned} s &= \left( 1 - \frac{1}{p} \right)^2 \end{aligned}

This gives us the probability that a random tree is hopeless when we sample according to Treesp\text{Trees}_p.

Note in particular that:

So Alex almost surely cannot win when p1/2p \le 1/2. This establishes that q1/2q \ge 1/2.

It also establishes the general techniques we will be using for the full solution: convert winnability into a predicate on trees, convert this predicate into a set of equations on probabilities, and then finally try to solve these equations analytically.

There is a little bit of handwaving involved here — to do this rigorously we would need to stipulate that Hopeless\text{Hopeless} is the minimal predicate satisfying our definitional equation, as well as explain why it’s okay for ss to exceed 1 when it ostensibly represents a probability. But I’m content with this level of rigor.

Tackling the original problem

Since the two players take turns moving in this situation, it makes to define winnability using two mutually recursive predicates.

{WA((1,τ1)(2,τ2))...((1=A)WB(τ1))((2=A)WB(τ2))WB((1,τ1)(2,τ2))...((1=A)WA(τ1))((2=A)WA(τ2)) \left\{ \begin{aligned} W_{\text{A}} \left( \begin{array}{c} \bigcirc \\ {\scriptstyle (\ell_1, \tau_1)} \quad {\scriptstyle (\ell_2, \tau_2)} \\ \end{array} \right) & \triangleq \begin{split} & \phantom{...} \\ & ((\ell_1 = \text{A}) \land W_{\text{B}} (\tau_1)) \, \lor \\ & ((\ell_2 = \text{A}) \land W_{\text{B}} (\tau_2)) \end{split} \\ W_{\text{B}} \left( \begin{array}{c} \bigcirc \\ {\scriptstyle (\ell_1, \tau_1)} \quad {\scriptstyle (\ell_2, \tau_2)} \\ \end{array} \right) & \triangleq \begin{split} & \phantom{...} \\ & ((\ell_1 = \text{A}) \land W_{\text{A}} (\tau_1)) \, \land \\ & ((\ell_2 = \text{A}) \land W_{\text{A}} (\tau_2)) \end{split} \end{aligned} \right.

Notice that the only difference between these predicates is that the first one is disjunctive in the branches (since Alex can choose which branch to take) whereas the second one is conjunctive (since Alex must assume the branch will be taken adversarially).

Again write this in terms of branches to get:

{WA((1,τ1)(2,τ2))HB(1,τ1)HB(2,τ2)WB((1,τ1)(2,τ2))HA(1,τ1)HA(2,τ2)HA(,τ)(=A)WA(τ)HB(,τ)(=A)WB(τ) \left\{ \begin{aligned} W_{\text{A}} \left( \begin{array}{c} \bigcirc \\ {\scriptstyle (\ell_1, \tau_1)} \quad {\scriptstyle (\ell_2, \tau_2)} \\ \end{array} \right) & \triangleq H_{\text{B}} (\ell_1, \tau_1) \lor H_{\text{B}} (\ell_2, \tau_2) \\ W_{\text{B}} \left( \begin{array}{c} \bigcirc \\ {\scriptstyle (\ell_1, \tau_1)} \quad {\scriptstyle (\ell_2, \tau_2)} \\ \end{array} \right) & \triangleq H_{\text{A}} (\ell_1, \tau_1) \land H_{\text{A}} (\ell_2, \tau_2) \\ H_{\text{A}} (\ell, \tau) & \triangleq (\ell = \text{A}) \land W_{\text{A}}(\tau) \\ H_{\text{B}} (\ell, \tau) & \triangleq (\ell = \text{A}) \land W_{\text{B}}(\tau) \end{aligned} \right.

Now let’s attach corresponding probabilities wA,wB,hA,hBw_{\text{A}}, w_{\text{B}}, h_{\text{A}}, h_{\text{B}} to these predicates. We are interested in the values of pp for which wA>0w_{\text{A}} > 0, but this is equivalent to hA>0h_{\text{A}} > 0, and it will make the math easier if we focus on that.

{wA=1(1hB)2wB=hA2hA=pwAhB=pwB    {hA=phB(2hB)hB=phA2    hA=p2hA2(2phA2)    hA is a fixed point of the map fp:xp2x2(2px2). \begin{aligned} & \left\{ \begin{aligned} w_{\text{A}} &= 1 - (1 - h_{\text{B}})^2 \\ w_{\text{B}} &= h_{\text{A}}^2 \\ h_{\text{A}} &= p w_{\text{A}} \\ h_{\text{B}} &= p w_{\text{B}} \\ \end{aligned} \right. \\ \iff & \left\{ \begin{aligned} h_{\text{A}} &= p h_{\text{B}} (2 - h_{\text{B}}) \\ h_{\text{B}} &= p h_{\text{A}}^2 \\ \end{aligned} \right. \\ \iff & \quad h_{\text{A}} = p^2 h_{\text{A}}^2 (2 - p h_{\text{A}}^2) \\ \iff & \quad h_{\text{A}} \text{ is a fixed point of the map } \\ & \quad f_p : x \mapsto p^2 x^2 (2 - p x^2). \end{aligned}

The last step here might seem redundant, but talking about fixed points hints at the idea that we might be able to better understand the problem by understanding the dynamics of the map fpf_p. On its own, trying to solve the equation x=p2x2(2px2)x = p^2 x^2 (2 - p x^2) analytically for arbitrary pp isn’t promising. We can get the solution x=0x = 0, but then we’re left with an ugly cubic.

Remember, though, that we aren’t really looking to compute the fixed points of fpf_p for arbitrary pp but rather to find a boundary value of pp with regards to the fixed point behavior of the map.

Inspecting the graph visually, we can see that when pp is sufficiently high, there are three fixed points: a stable fixed point at x=0x = 0, an unstable fixed point (fp(x)>1)\left( |f_p’(x)| > 1 \right) to its right, and a stable fixed point (fp(x)<1)\left( |f_p’(x)| < 1 \right) further to the right of that.

Graph of the map fpf_p (purple) compared against the identity map (red) with p=0.97p = 0.97.

On the other hand, for smaller values of pp there are no fixed points except at 0.

Graph of the map fpf_p (purple) compared against the identity map (red) with p=0.90p = 0.90.

So we should expect that at the boundary value, the two fixed points merge into a semi-stable fixed point at which the graph is tangent to the y=xy = x line:

Graph of the map fpf_p (purple) compared against the identity map (red) with p=qp = q.

In other words, we have that fqf_q has a fixed point 0<x<10 < x < 1 satisfying:

{x=f(x)1=f(x)    {x=q2x2(2qx2)1=q2(2x(2qx2)+x2(2px))=q2(4x2qx32qx3)=4q2x(1qx2)    {1=q2x(2qx2)1=4q2x(1qx2)    q2x(2qx2)=4q2x(1qx2)    (2qx2)=4(1qx2)    {23=qx2x=q(qx2)(2qx2)=q(23)(223)=83q    q=3423. \begin{aligned} & \left\{ \begin{aligned} x &= f(x) \\ 1 &= f'(x) \\ \end{aligned} \right. \\ \implies & \left\{ \begin{aligned} x &= q^2 x^2 (2 - q x^2) \\ 1 &= q^2 (2 x (2 - q x^2) + x^2 (-2p x)) \\ &= q^2 (4 x - 2 q x^3 - 2 q x^3) \\ &= 4 q^2 x (1 - q x^2) \\ \end{aligned} \right. \\ \implies & \left\{ \begin{aligned} 1 &= q^2 x (2 - q x^2) \\ 1 &= 4 q^2 x (1 - q x^2) \\ \end{aligned} \right. \\ \implies & q^2 x (2 - q x^2) = 4 q^2 x (1 - q x^2) \\ \implies & (2 - q x^2) = 4 (1 - q x^2) \\ \implies & \left\{ \begin{aligned} \frac{2}{3} &= q x^2 \\ x &= q (q x^2) (2 - q x^2) \\ &= q \left( \frac{2}{3} \right) \left( 2 - \frac{2}{3} \right) \\ &= \frac{8}{3} q \end{aligned} \right. \\ \implies & \quad q = \frac{3}{4} \sqrt[3]{2}. \end{aligned}

So we have q0.94494q \approx 0.94494.

Conclusion

That was a fun puzzle!