Metamath Proof Explorer


Theorem modprm0

Description: For two positive integers less than a given prime number there is always a nonnegative integer (less than the given prime number) so that the sum of one of the two positive integers and the other of the positive integers multiplied by the nonnegative integer is 0 ( modulo the given prime number). (Contributed by Alexander van der Vekens, 17-May-2018)

Ref Expression
Assertion modprm0 PN1..^PI1..^Pj0..^PI+j NmodP=0

Proof

Step Hyp Ref Expression
1 reumodprminv PN1..^P∃!r1P1NrmodP=1
2 reurex ∃!r1P1NrmodP=1r1P1NrmodP=1
3 prmz PP
4 3 3ad2ant1 PN1..^PI1..^PP
5 4 adantl r1P1NrmodP=1PN1..^PI1..^PP
6 elfzelz r1P1r
7 6 adantr r1P1NrmodP=1r
8 elfzoelz I1..^PI
9 8 3ad2ant3 PN1..^PI1..^PI
10 zmulcl rIr I
11 7 9 10 syl2an r1P1NrmodP=1PN1..^PI1..^Pr I
12 5 11 zsubcld r1P1NrmodP=1PN1..^PI1..^PPr I
13 prmnn PP
14 13 3ad2ant1 PN1..^PI1..^PP
15 14 adantl r1P1NrmodP=1PN1..^PI1..^PP
16 zmodfzo Pr IPPr ImodP0..^P
17 12 15 16 syl2anc r1P1NrmodP=1PN1..^PI1..^PPr ImodP0..^P
18 8 zred I1..^PI
19 18 3ad2ant3 PN1..^PI1..^PI
20 19 adantl r1P1NrmodP=1PN1..^PI1..^PI
21 13 nnred PP
22 21 3ad2ant1 PN1..^PI1..^PP
23 22 adantl r1P1NrmodP=1PN1..^PI1..^PP
24 6 zred r1P1r
25 24 adantr r1P1NrmodP=1r
26 remulcl rIr I
27 25 19 26 syl2an r1P1NrmodP=1PN1..^PI1..^Pr I
28 23 27 resubcld r1P1NrmodP=1PN1..^PI1..^PPr I
29 elfzoelz N1..^PN
30 29 3ad2ant2 PN1..^PI1..^PN
31 30 adantl r1P1NrmodP=1PN1..^PI1..^PN
32 13 nnrpd PP+
33 32 3ad2ant1 PN1..^PI1..^PP+
34 33 adantl r1P1NrmodP=1PN1..^PI1..^PP+
35 modaddmulmod IPr INP+I+Pr ImodP NmodP=I+Pr I NmodP
36 20 28 31 34 35 syl31anc r1P1NrmodP=1PN1..^PI1..^PI+Pr ImodP NmodP=I+Pr I NmodP
37 13 nncnd PP
38 37 3ad2ant1 PN1..^PI1..^PP
39 38 adantl r1P1NrmodP=1PN1..^PI1..^PP
40 6 zcnd r1P1r
41 40 adantr r1P1NrmodP=1r
42 8 zcnd I1..^PI
43 42 3ad2ant3 PN1..^PI1..^PI
44 mulcl rIr I
45 41 43 44 syl2an r1P1NrmodP=1PN1..^PI1..^Pr I
46 29 zcnd N1..^PN
47 46 3ad2ant2 PN1..^PI1..^PN
48 47 adantl r1P1NrmodP=1PN1..^PI1..^PN
49 39 45 48 subdird r1P1NrmodP=1PN1..^PI1..^PPr I N=P Nr I N
50 49 oveq2d r1P1NrmodP=1PN1..^PI1..^PI+Pr I N=I+P N-r I N
51 50 oveq1d r1P1NrmodP=1PN1..^PI1..^PI+Pr I NmodP=I+P N-r I NmodP
52 mulcom PNP N=NP
53 37 46 52 syl2an PN1..^PP N=NP
54 53 oveq1d PN1..^PP NmodP=NPmodP
55 mulmod0 NP+NPmodP=0
56 29 32 55 syl2anr PN1..^PNPmodP=0
57 54 56 eqtrd PN1..^PP NmodP=0
58 57 3adant3 PN1..^PI1..^PP NmodP=0
59 58 adantl r1P1NrmodP=1PN1..^PI1..^PP NmodP=0
60 41 adantr r1P1NrmodP=1PN1..^PI1..^Pr
61 43 adantl r1P1NrmodP=1PN1..^PI1..^PI
62 60 61 48 mul32d r1P1NrmodP=1PN1..^PI1..^Pr I N=r N I
63 62 oveq1d r1P1NrmodP=1PN1..^PI1..^Pr I NmodP=r N ImodP
64 29 zred N1..^PN
65 64 3ad2ant2 PN1..^PI1..^PN
66 remulcl rNr N
67 25 65 66 syl2an r1P1NrmodP=1PN1..^PI1..^Pr N
68 9 adantl r1P1NrmodP=1PN1..^PI1..^PI
69 modmulmod r NIP+r NmodP ImodP=r N ImodP
70 67 68 34 69 syl3anc r1P1NrmodP=1PN1..^PI1..^Pr NmodP ImodP=r N ImodP
71 63 70 eqtr4d r1P1NrmodP=1PN1..^PI1..^Pr I NmodP=r NmodP ImodP
72 59 71 oveq12d r1P1NrmodP=1PN1..^PI1..^PP NmodPr I NmodP=0r NmodP ImodP
73 72 oveq1d r1P1NrmodP=1PN1..^PI1..^PP NmodPr I NmodPmodP=0r NmodP ImodPmodP
74 remulcl PNP N
75 21 64 74 syl2an PN1..^PP N
76 75 3adant3 PN1..^PI1..^PP N
77 76 adantl r1P1NrmodP=1PN1..^PI1..^PP N
78 65 adantl r1P1NrmodP=1PN1..^PI1..^PN
79 27 78 remulcld r1P1NrmodP=1PN1..^PI1..^Pr I N
80 modsubmodmod P Nr I NP+P NmodPr I NmodPmodP=P Nr I NmodP
81 77 79 34 80 syl3anc r1P1NrmodP=1PN1..^PI1..^PP NmodPr I NmodPmodP=P Nr I NmodP
82 mulcom NrNr=r N
83 47 40 82 syl2anr r1P1PN1..^PI1..^PNr=r N
84 83 oveq1d r1P1PN1..^PI1..^PNrmodP=r NmodP
85 84 eqeq1d r1P1PN1..^PI1..^PNrmodP=1r NmodP=1
86 85 biimpd r1P1PN1..^PI1..^PNrmodP=1r NmodP=1
87 86 impancom r1P1NrmodP=1PN1..^PI1..^Pr NmodP=1
88 87 imp r1P1NrmodP=1PN1..^PI1..^Pr NmodP=1
89 88 oveq1d r1P1NrmodP=1PN1..^PI1..^Pr NmodP I=1 I
90 89 oveq1d r1P1NrmodP=1PN1..^PI1..^Pr NmodP ImodP=1 ImodP
91 90 oveq2d r1P1NrmodP=1PN1..^PI1..^P0r NmodP ImodP=01 ImodP
92 91 oveq1d r1P1NrmodP=1PN1..^PI1..^P0r NmodP ImodPmodP=01 ImodPmodP
93 61 mullidd r1P1NrmodP=1PN1..^PI1..^P1 I=I
94 93 oveq1d r1P1NrmodP=1PN1..^PI1..^P1 ImodP=ImodP
95 32 18 anim12ci PI1..^PIP+
96 elfzo2 I1..^PI1PI<P
97 eluz2 I11I1I
98 0red I0
99 1red I1
100 zre II
101 98 99 100 3jca I01I
102 101 adantr I1I01I
103 0le1 01
104 103 a1i I01
105 104 anim1i I1I011I
106 letr 01I011I0I
107 102 105 106 sylc I1I0I
108 107 3adant1 1I1I0I
109 97 108 sylbi I10I
110 109 3ad2ant1 I1PI<P0I
111 simp3 I1PI<PI<P
112 110 111 jca I1PI<P0II<P
113 96 112 sylbi I1..^P0II<P
114 113 adantl PI1..^P0II<P
115 95 114 jca PI1..^PIP+0II<P
116 115 3adant2 PN1..^PI1..^PIP+0II<P
117 116 adantl r1P1NrmodP=1PN1..^PI1..^PIP+0II<P
118 modid IP+0II<PImodP=I
119 117 118 syl r1P1NrmodP=1PN1..^PI1..^PImodP=I
120 94 119 eqtrd r1P1NrmodP=1PN1..^PI1..^P1 ImodP=I
121 120 oveq2d r1P1NrmodP=1PN1..^PI1..^P01 ImodP=0I
122 121 oveq1d r1P1NrmodP=1PN1..^PI1..^P01 ImodPmodP=0ImodP
123 92 122 eqtrd r1P1NrmodP=1PN1..^PI1..^P0r NmodP ImodPmodP=0ImodP
124 73 81 123 3eqtr3d r1P1NrmodP=1PN1..^PI1..^PP Nr I NmodP=0ImodP
125 124 oveq2d r1P1NrmodP=1PN1..^PI1..^PI+P Nr I NmodP=I+0ImodP
126 125 oveq1d r1P1NrmodP=1PN1..^PI1..^PI+P Nr I NmodPmodP=I+0ImodPmodP
127 77 79 resubcld r1P1NrmodP=1PN1..^PI1..^PP Nr I N
128 modadd2mod P Nr I NIP+I+P Nr I NmodPmodP=I+P N-r I NmodP
129 127 20 34 128 syl3anc r1P1NrmodP=1PN1..^PI1..^PI+P Nr I NmodPmodP=I+P N-r I NmodP
130 0red I1..^P0
131 130 18 resubcld I1..^P0I
132 131 adantl PI1..^P0I
133 18 adantl PI1..^PI
134 32 adantr PI1..^PP+
135 132 133 134 3jca PI1..^P0IIP+
136 135 3adant2 PN1..^PI1..^P0IIP+
137 136 adantl r1P1NrmodP=1PN1..^PI1..^P0IIP+
138 modadd2mod 0IIP+I+0ImodPmodP=I+0-ImodP
139 137 138 syl r1P1NrmodP=1PN1..^PI1..^PI+0ImodPmodP=I+0-ImodP
140 0cnd I1..^P0
141 42 140 pncan3d I1..^PI+0-I=0
142 141 3ad2ant3 PN1..^PI1..^PI+0-I=0
143 142 adantl r1P1NrmodP=1PN1..^PI1..^PI+0-I=0
144 143 oveq1d r1P1NrmodP=1PN1..^PI1..^PI+0-ImodP=0modP
145 0mod P+0modP=0
146 32 145 syl P0modP=0
147 146 3ad2ant1 PN1..^PI1..^P0modP=0
148 147 adantl r1P1NrmodP=1PN1..^PI1..^P0modP=0
149 139 144 148 3eqtrd r1P1NrmodP=1PN1..^PI1..^PI+0ImodPmodP=0
150 126 129 149 3eqtr3d r1P1NrmodP=1PN1..^PI1..^PI+P N-r I NmodP=0
151 36 51 150 3eqtrd r1P1NrmodP=1PN1..^PI1..^PI+Pr ImodP NmodP=0
152 oveq1 j=Pr ImodPj N=Pr ImodP N
153 152 oveq2d j=Pr ImodPI+j N=I+Pr ImodP N
154 153 oveq1d j=Pr ImodPI+j NmodP=I+Pr ImodP NmodP
155 154 eqeq1d j=Pr ImodPI+j NmodP=0I+Pr ImodP NmodP=0
156 155 rspcev Pr ImodP0..^PI+Pr ImodP NmodP=0j0..^PI+j NmodP=0
157 17 151 156 syl2anc r1P1NrmodP=1PN1..^PI1..^Pj0..^PI+j NmodP=0
158 157 ex r1P1NrmodP=1PN1..^PI1..^Pj0..^PI+j NmodP=0
159 158 rexlimiva r1P1NrmodP=1PN1..^PI1..^Pj0..^PI+j NmodP=0
160 1 2 159 3syl PN1..^PPN1..^PI1..^Pj0..^PI+j NmodP=0
161 160 3adant3 PN1..^PI1..^PPN1..^PI1..^Pj0..^PI+j NmodP=0
162 161 pm2.43i PN1..^PI1..^Pj0..^PI+j NmodP=0