A formal study of Moessner's sieve