Detection of arithmetic violations during sleep