In David Morin's Introduction to Classical Mechanics, he poses the following problem: a pendulum of mass $m$ is fixed onto a block of mass $M$ with a rod of length $l$. The block of mass $M$ is free to move horizontally, but fixed vertically. See figure below.
The position of the little mass $m$ is $(x + l \sin\theta,-l\cos\theta)$. Taking the time derivative then resolving the speed, we can find the total kinetic energy of the system. The potential energy is the gravitational potential energy derived from the changes in height of the little mass $m$. $$L = \frac{1}{2}M\dot{x}^2+ \frac{1}{2}m(\dot{x}^2 +l^2\dot{\theta}^2+2l\dot{x}\dot{\theta}\cos\theta) + mgl\cos\theta$$
This lagragian tells us that the generalized momentum of the block is conserved, since $\frac{d}{dt}\frac{\partial L}{\partial \dot{x}} = \frac{\partial L}{\partial x} = 0$.
But this doesn't make any physical sense, since if we set the pendulum to oscillate, the movement of the pendulum should pull on the big block, making the big block oscillate as well. At the very least, the motion of the little pendulum should affect the motion of the block in some way, but that is not reflected in the lagrangian.
My question is, how would one go about modifying the lagrangian so that the forces between the big block and the little block is taken into account? I have looked for this online, but every resource that tackles this problem assume the independence of the $x$ (position of the block) and the position of the pendulum.
A possible way to modify the Lagrangian might be to add a potential term that takes into account the force $T$ by which the rod pulls on the block (and the pendulum). But the trouble is that $T$ will change with time, so I'm unsure how to proceed. Any suggestions or thoughts would be greatly appreciated.
A PDF containing the statement of the problem and it's solution is available here. (Page 43)