Mathlib.Data.Num.Prime
15 declarations. Mathlib docs · Source
theorem PosNum.minFac.match_1.congr_eq_1 E1 #
∀ (motive : PosNum → Sort u_1) (x : PosNum) (h_1 : Unit → motive PosNum.one) (h_2 : (a : PosNum) → motive a.bit0)
(h_3 : (n : PosNum) → motive n.bit1),
x = PosNum.one →
(match x with
| PosNum.one => h_1 ()
| a.bit0 => h_2 a
| n.bit1 => h_3 n) ≍
h_1 ()
theorem PosNum.minFacAux.match_1.congr_eq_1 E1 #
∀ (motive : ℕ → PosNum → Sort u_1) (x : ℕ) (x_1 : PosNum) (h_1 : (x : PosNum) → motive 0 x)
(h_2 : (fuel : ℕ) → (k : PosNum) → motive fuel.succ k) (x_2 : PosNum),
x = 0 →
x_1 = x_2 →
(match x, x_1 with
| 0, x => h_1 x
| fuel.succ, k => h_2 fuel k) ≍
h_1 x_2
theorem PosNum.minFac.match_1.congr_eq_3 E1 #
∀ (motive : PosNum → Sort u_1) (x : PosNum) (h_1 : Unit → motive PosNum.one) (h_2 : (a : PosNum) → motive a.bit0)
(h_3 : (n : PosNum) → motive n.bit1) (n : PosNum),
x = n.bit1 →
(match x with
| PosNum.one => h_1 ()
| a.bit0 => h_2 a
| n.bit1 => h_3 n) ≍
h_3 n
theorem PosNum.minFacAux.match_1.congr_eq_2 E1 #
∀ (motive : ℕ → PosNum → Sort u_1) (x : ℕ) (x_1 : PosNum) (h_1 : (x : PosNum) → motive 0 x)
(h_2 : (fuel : ℕ) → (k : PosNum) → motive fuel.succ k) (fuel : ℕ) (k : PosNum),
x = fuel.succ →
x_1 = k →
(match x, x_1 with
| 0, x => h_1 x
| fuel.succ, k => h_2 fuel k) ≍
h_2 fuel k
theorem PosNum.minFac.match_1.congr_eq_2 E1 #
∀ (motive : PosNum → Sort u_1) (x : PosNum) (h_1 : Unit → motive PosNum.one) (h_2 : (a : PosNum) → motive a.bit0)
(h_3 : (n : PosNum) → motive n.bit1) (a : PosNum),
x = a.bit0 →
(match x with
| PosNum.one => h_1 ()
| a.bit0 => h_2 a
| n.bit1 => h_3 n) ≍
h_2 a
def PosNum.minFacAux E0 #
PosNum → ℕ → PosNum → PosNum
Auxiliary function for computing the smallest prime factor of a PosNum. Unlike
Nat.minFacAux, we use a natural number fuel variable that is set to an upper bound on the
number of iterations. It is initialized to the number n we are determining primality for. Even
though this is exponential in the input (since it is a Nat, not a Num), it will get lazily
evaluated during kernel reduction, so we will only require about sqrt n unfoldings, for the
sqrt n iterations of the loop.
theorem PosNum.minFacAux_to_nat E1 #
∀ {fuel : ℕ} {n k : PosNum}, (↑n).sqrt < fuel + ↑k.bit1 → ↑(n.minFacAux fuel k) = (↑n).minFacAux ↑k.bit1
def PosNum.minFac E1 #
PosNum → PosNum
Returns the smallest prime factor of n ≠ 1.
theorem PosNum.minFac_to_nat E0 #
∀ (n : PosNum), ↑n.minFac = (↑n).minFac
def PosNum.Prime E1 #
PosNum → Prop
Primality predicate for a PosNum.
instance PosNum.decidablePrime E0 #
DecidablePred PosNum.Prime
def Num.minFac E1 #
Num → PosNum
Returns the smallest prime factor of n ≠ 1.
theorem Num.minFac_to_nat E0 #
∀ (n : Num), ↑n.minFac = (↑n).minFac
def Num.Prime E1 #
Num → Prop
Primality predicate for a Num.
instance Num.decidablePrime E0 #
DecidablePred Num.Prime