Hi I get the basics of beta reduction e.g.
$$(\lambda var.body)arg $$
you just replace the occurrences of var with arg in body.
However what happens here?
$$(\lambda x.xx)(\lambda x.xx) \rightsquigarrow_\beta (\lambda x.xx)(\lambda x.xx)$$
Let's call them $A$ and $B$, so I replace all occurrences of $x$ in $A$ with $xx$ (from $b$) and throw away $B$'s lamda. Giving me
$$(\lambda x.xx)(\lambda x.xx) \rightsquigarrow_\beta \lambda x.xxxx$$
Instead of
$$ (\lambda x.xx)(\lambda x.xx)$$
Can anyone explain where I'm going wrong?
$$ (\lambda x ~.~ xx)(\lambda z ~.~ zz) ~ \rightarrow_{\beta} ~ (xx)[x \mapsto (\lambda z ~.~ zz)] ~=~ (\lambda z ~.~ zz)(\lambda z ~.~ zz) $$