Yes, although obviously you can't have a perpetual motion machine; the Stirling engine also moves more energy from hot to cold than it can emit as useful work.
Both the Stirling engine and the AC unit are using the Carnot cycle (simplification), and going around the expansion-heat-transfer cycle in opposite directions.
Both the Stirling engine and the AC unit are using the Carnot cycle (simplification), and going around the expansion-heat-transfer cycle in opposite directions.