Solution (source code)

= Solution

For <events> with $\mathbb P(B)>0$, the <conditional probability> is
$$
\boxed{\mathbb P(A\mid B)=\frac{\mathbb P(A\cap B)}{\mathbb P(B)}.}
$$
Use the <sample space> $\Omega=\{1,2,3,4\}\times\{0,1\}^4$, where the first coordinate is the chosen coin and the other coordinates record which of its two physically distinguished faces lands upwards on each toss. There are $4\cdot16=64$ equally likely elementary outcomes. Label the double-headed coin by one. For that coin both face indices mean heads; for each other coin only face index one means heads. In particular, strings of observed heads and tails are not equally likely outcomes.

Let $E$ be the <event> that the first three tosses show heads. With coin one all sixteen face-index strings are permitted. For each ordinary coin the first three indices must be one and the fourth is free, giving two strings. Thus $|E|=16+3\cdot2=22$. Of these outcomes, sixteen from the double-headed coin and one from each ordinary coin also have a fourth head. Hence
$$
\boxed{\mathbb P(\text{fourth head}\mid E)=\frac{16+3}{22}=\frac{19}{22}.}
$$
Equivalently, <Bayes' theorem> gives <conditional probability> $8/11$ of having selected the double-headed coin after $E$; the fourth-head <probability> is then $8/11+(3/11)(1/2)=19/22$. The tosses are <independent> conditional on the selected coin, while mixing over the same coin explains their unconditional dependence.