Perpetual motion is motion of bodies that continues indefinitely. A perpetual motion machine is a hypothetical machine that can do work indefinitely 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 even at very grand scales. 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.
The laws of thermodynamics apply to closed linear systems. In 2017 new states of matter that violate the conservation of energy, Time crystals, were discovered which may allow for perpetual motion by bypassing the laws of thermodynamics
The history of perpetual motion machines dates back to the Middle Ages. For millennia, it was not clear whether perpetual motion devices were possible or not, but the development of modern theories of thermodynamics has shown that they are impossible. Despite this, many attempts have been made to construct such machines, continuing into modern times. Modern designers and proponents often use other terms, such as "over unity", to describe their inventions.
Oh ye seekers after perpetual motion, how many vain chimeras have you pursued? Go and take your place with the alchemists.
There is a scientific consensus that perpetual motion in an isolated system violates either the first law of thermodynamics, the second law of thermodynamics, or both. The first law of thermodynamics is a version of the law of conservation of energy. The second law can be phrased in several different ways, the most intuitive of which is that heat flows spontaneously from hotter to colder places; relevant here is that the law observes that in every macroscopic process, there is friction or something close to it; another statement is that no heat engine (an engine which produces work while moving heat from a high temperature to a low temperature) can be more efficient than a Carnot heat engine.