Metamath Proof Explorer


Theorem prmgaplem5

Description: Lemma for prmgap : for each integer greater than 2 there is a smaller prime closest to this integer, i.e. there is a smaller prime and no other prime is between this prime and the integer. (Contributed by AV, 9-Aug-2020)

Ref Expression
Assertion prmgaplem5 N 3 p p < N z p + 1 ..^ N z

Proof

Step Hyp Ref Expression
1 elrabi r q | q < N r
2 1 ad2antlr N 3 r q | q < N z q | q < N z r r
3 breq1 p = r p < N r < N
4 oveq1 p = r p + 1 = r + 1
5 4 oveq1d p = r p + 1 ..^ N = r + 1 ..^ N
6 5 raleqdv p = r z p + 1 ..^ N z z r + 1 ..^ N z
7 3 6 anbi12d p = r p < N z p + 1 ..^ N z r < N z r + 1 ..^ N z
8 7 adantl N 3 r q | q < N z q | q < N z r p = r p < N z p + 1 ..^ N z r < N z r + 1 ..^ N z
9 breq1 q = r q < N r < N
10 9 elrab r q | q < N r r < N
11 10 simprbi r q | q < N r < N
12 11 ad2antlr N 3 r q | q < N z q | q < N z r r < N
13 elfzo2 z r + 1 ..^ N z r + 1 N z < N
14 breq1 q = z q < N z < N
15 simpl z z r + 1 N z < N z
16 simpr3 z z r + 1 N z < N z < N
17 14 15 16 elrabd z z r + 1 N z < N z q | q < N
18 17 adantrl z N 3 r q | q < N z r + 1 N z < N z q | q < N
19 eluz2 z r + 1 r + 1 z r + 1 z
20 prmz r r
21 zltp1le r z r < z r + 1 z
22 20 21 sylan r z r < z r + 1 z
23 prmnn r r
24 23 nnred r r
25 zre z z
26 ltnle r z r < z ¬ z r
27 26 biimpd r z r < z ¬ z r
28 24 25 27 syl2an r z r < z ¬ z r
29 pm2.21 ¬ z r z r z
30 28 29 syl6 r z r < z z r z
31 22 30 sylbird r z r + 1 z z r z
32 31 expcom z r r + 1 z z r z
33 32 com23 z r + 1 z r z r z
34 33 a1i r + 1 z r + 1 z r z r z
35 34 3imp r + 1 z r + 1 z r z r z
36 19 35 sylbi z r + 1 r z r z
37 36 3ad2ant1 z r + 1 N z < N r z r z
38 1 37 syl5com r q | q < N z r + 1 N z < N z r z
39 38 adantl N 3 r q | q < N z r + 1 N z < N z r z
40 39 imp N 3 r q | q < N z r + 1 N z < N z r z
41 40 adantl z N 3 r q | q < N z r + 1 N z < N z r z
42 18 41 embantd z N 3 r q | q < N z r + 1 N z < N z q | q < N z r z
43 42 ex z N 3 r q | q < N z r + 1 N z < N z q | q < N z r z
44 df-nel z ¬ z
45 2a1 z N 3 r q | q < N z r + 1 N z < N z q | q < N z r z
46 44 45 sylbir ¬ z N 3 r q | q < N z r + 1 N z < N z q | q < N z r z
47 43 46 pm2.61i N 3 r q | q < N z r + 1 N z < N z q | q < N z r z
48 47 impancom N 3 r q | q < N z q | q < N z r z r + 1 N z < N z
49 13 48 syl5bi N 3 r q | q < N z q | q < N z r z r + 1 ..^ N z
50 49 ex N 3 r q | q < N z q | q < N z r z r + 1 ..^ N z
51 50 ralimdv2 N 3 r q | q < N z q | q < N z r z r + 1 ..^ N z
52 51 imp N 3 r q | q < N z q | q < N z r z r + 1 ..^ N z
53 12 52 jca N 3 r q | q < N z q | q < N z r r < N z r + 1 ..^ N z
54 2 8 53 rspcedvd N 3 r q | q < N z q | q < N z r p p < N z p + 1 ..^ N z
55 eqid q | q < N = q | q < N
56 55 prmgaplem3 N 3 r q | q < N z q | q < N z r
57 54 56 r19.29a N 3 p p < N z p + 1 ..^ N z