Documentation

HexPrimality.MillerRabin

Split off the factors of two: oddSplitAux fuel m = (s, d) with m = 2 ^ s * d and d odd, provided the fuel bounds the number of factors of two.

Equations
Instances For

    Split m as 2 ^ s * d with d odd, returning (s, d); oddSplit 0 = (0, 0).

    Equations
    Instances For
      theorem Hex.Nat.oddSplit_spec (m : Nat) (hm : m 0) :
      2 ^ (oddSplit m).fst * (oddSplit m).snd = m (oddSplit m).snd % 2 = 1

      Correctness of the split: for m ≠ 0, m = 2 ^ s * d with d odd.

      def Hex.Nat.mrWitnessLoop (n : Nat) :
      NatNatBool

      The squaring loop of the strong test: starting from x = a ^ (2 ^ 1 * d) % n, true iff some square in the next i steps hits n - 1.

      Equations
      Instances For

        Core of the strong test on the residue x = a ^ d % n, with n - 1 = 2 ^ s * d.

        Equations
        Instances For

          The Miller-Rabin test at base a. false is a proof of compositeness; true is evidence and nothing more. The branch list is part of the specification: in particular the a % n = 0 branch returns true (inconclusive; such a base carries no information), which is what makes the compositeness theorem true at small n.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            The first 13 primes: sufficient witnesses for n < 3.3 · 10^24 by Sorenson-Webster, a fact used only to decide what to try and never in a proof.

            Equations
            Instances For

              Run millerRabin over a base list. true proves nothing about n; it is consumed only as a filter ahead of certificate construction.

              Equations
              Instances For

                A prime passes the Miller-Rabin test at every base: the contrapositive of the compositeness theorem, proved branch by branch.

                A Miller-Rabin witness proves compositeness. This is the theorem the whole test exists for; there is deliberately no converse.