Perpetual motion is the motion of bodies that continues forever. A perpetual motion machine is a hypothetical machine that can do work infinitely without an energy source. This kind of machine is impossible, as it would violate the first or second law of thermodynamics.
These laws of thermodynamics apply regardless of the size of the system. For example, the motions and rotations of celestial bodies such as planets may appear perpetual, but are actually subject to many processes that slowly dissipate their kinetic energy, such as solar wind, interstellar medium resistance, gravitational radiation and thermal radiation, so they will not keep moving forever.
Thus, machines that extract energy from finite sources will not operate indefinitely, because they are driven by the energy stored in the source, which will eventually be exhausted. A common example is devices powered by ocean currents, whose energy is ultimately derived from the Sun, which itself will eventually burn out. Machines powered by more obscure sources have been proposed, but are subject to the same inescapable laws, and will eventually wind down.
In 2017, new states of matter, time crystals, were discovered in which on a microscopic scale the component atoms are in continual repetitive motion, thus satisfying the literal definition of “perpetual motion”. However, these do not constitute perpetual motion machines in the traditional sense or violate thermodynamic laws because they are in their quantum ground state, so no energy can be extracted from them; they exhibit motion without energy.