Let's look at this sequentially.
Assume that Lunatone starts out as a lvl 1 Pokemon in the wild. It's known moves will be Harden, Magic Room, Rock Throw and Tackle (in the given sequence). This means Rock Throw will not be learned again at lvl 5, and will become the third move to be replaced.
Hence, in the end when Lunatone is lvl 17, it's moves will be Tackle, Hypnosis, Rock Polish and Psywave. Yeah confusing stuff.
Source
Hope I helped!