Metamath Proof Explorer


Theorem fldivp1

Description: The difference between the floors of adjacent fractions is either 1 or 0. (Contributed by Mario Carneiro, 8-Mar-2014)

Ref Expression
Assertion fldivp1 M N M + 1 N M N = if N M + 1 1 0

Proof

Step Hyp Ref Expression
1 nnz N N
2 nnne0 N N 0
3 peano2z M M + 1
4 3 adantr M N M + 1
5 dvdsval2 N N 0 M + 1 N M + 1 M + 1 N
6 1 2 4 5 syl2an23an M N N M + 1 M + 1 N
7 6 biimpa M N N M + 1 M + 1 N
8 flid M + 1 N M + 1 N = M + 1 N
9 7 8 syl M N N M + 1 M + 1 N = M + 1 N
10 nnm1nn0 N N 1 0
11 10 nn0red N N 1
12 10 nn0ge0d N 0 N 1
13 nnre N N
14 nngt0 N 0 < N
15 divge0 N 1 0 N 1 N 0 < N 0 N 1 N
16 11 12 13 14 15 syl22anc N 0 N 1 N
17 16 ad2antlr M N N M + 1 0 N 1 N
18 13 ltm1d N N 1 < N
19 nncn N N
20 19 mulid1d N N 1 = N
21 18 20 breqtrrd N N 1 < N 1
22 1re 1
23 22 a1i N 1
24 ltdivmul N 1 1 N 0 < N N 1 N < 1 N 1 < N 1
25 11 23 13 14 24 syl112anc N N 1 N < 1 N 1 < N 1
26 21 25 mpbird N N 1 N < 1
27 26 ad2antlr M N N M + 1 N 1 N < 1
28 nndivre N 1 N N 1 N
29 11 28 mpancom N N 1 N
30 29 ad2antlr M N N M + 1 N 1 N
31 flbi2 M + 1 N N 1 N M + 1 N + N 1 N = M + 1 N 0 N 1 N N 1 N < 1
32 7 30 31 syl2anc M N N M + 1 M + 1 N + N 1 N = M + 1 N 0 N 1 N N 1 N < 1
33 17 27 32 mpbir2and M N N M + 1 M + 1 N + N 1 N = M + 1 N
34 9 33 eqtr4d M N N M + 1 M + 1 N = M + 1 N + N 1 N
35 zcn M M
36 35 adantr M N M
37 ax-1cn 1
38 37 a1i M N 1
39 19 adantl M N N
40 36 38 39 ppncand M N M + 1 + N 1 = M + N
41 40 oveq1d M N M + 1 + N 1 N = M + N N
42 4 zcnd M N M + 1
43 subcl N 1 N 1
44 19 37 43 sylancl N N 1
45 44 adantl M N N 1
46 2 adantl M N N 0
47 42 45 39 46 divdird M N M + 1 + N 1 N = M + 1 N + N 1 N
48 41 47 eqtr3d M N M + N N = M + 1 N + N 1 N
49 36 39 39 46 divdird M N M + N N = M N + N N
50 48 49 eqtr3d M N M + 1 N + N 1 N = M N + N N
51 39 46 dividd M N N N = 1
52 51 oveq2d M N M N + N N = M N + 1
53 50 52 eqtrd M N M + 1 N + N 1 N = M N + 1
54 53 fveq2d M N M + 1 N + N 1 N = M N + 1
55 54 adantr M N N M + 1 M + 1 N + N 1 N = M N + 1
56 zre M M
57 nndivre M N M N
58 56 57 sylan M N M N
59 1z 1
60 fladdz M N 1 M N + 1 = M N + 1
61 58 59 60 sylancl M N M N + 1 = M N + 1
62 61 adantr M N N M + 1 M N + 1 = M N + 1
63 34 55 62 3eqtrrd M N N M + 1 M N + 1 = M + 1 N
64 zre M + 1 M + 1
65 3 64 syl M M + 1
66 nndivre M + 1 N M + 1 N
67 65 66 sylan M N M + 1 N
68 67 flcld M N M + 1 N
69 68 zcnd M N M + 1 N
70 58 flcld M N M N
71 70 zcnd M N M N
72 69 71 38 subaddd M N M + 1 N M N = 1 M N + 1 = M + 1 N
73 72 adantr M N N M + 1 M + 1 N M N = 1 M N + 1 = M + 1 N
74 63 73 mpbird M N N M + 1 M + 1 N M N = 1
75 iftrue N M + 1 if N M + 1 1 0 = 1
76 75 adantl M N N M + 1 if N M + 1 1 0 = 1
77 74 76 eqtr4d M N N M + 1 M + 1 N M N = if N M + 1 1 0
78 zmodcl M + 1 N M + 1 mod N 0
79 3 78 sylan M N M + 1 mod N 0
80 79 nn0red M N M + 1 mod N
81 resubcl M + 1 mod N 1 M + 1 mod N 1
82 80 22 81 sylancl M N M + 1 mod N 1
83 82 adantr M N ¬ N M + 1 M + 1 mod N 1
84 elnn0 M + 1 mod N 0 M + 1 mod N M + 1 mod N = 0
85 79 84 sylib M N M + 1 mod N M + 1 mod N = 0
86 85 ord M N ¬ M + 1 mod N M + 1 mod N = 0
87 id N N
88 dvdsval3 N M + 1 N M + 1 M + 1 mod N = 0
89 87 3 88 syl2anr M N N M + 1 M + 1 mod N = 0
90 86 89 sylibrd M N ¬ M + 1 mod N N M + 1
91 90 con1d M N ¬ N M + 1 M + 1 mod N
92 91 imp M N ¬ N M + 1 M + 1 mod N
93 nnm1nn0 M + 1 mod N M + 1 mod N 1 0
94 92 93 syl M N ¬ N M + 1 M + 1 mod N 1 0
95 94 nn0ge0d M N ¬ N M + 1 0 M + 1 mod N 1
96 13 14 jca N N 0 < N
97 96 ad2antlr M N ¬ N M + 1 N 0 < N
98 divge0 M + 1 mod N 1 0 M + 1 mod N 1 N 0 < N 0 M + 1 mod N 1 N
99 83 95 97 98 syl21anc M N ¬ N M + 1 0 M + 1 mod N 1 N
100 13 adantl M N N
101 80 ltm1d M N M + 1 mod N 1 < M + 1 mod N
102 nnrp N N +
103 modlt M + 1 N + M + 1 mod N < N
104 65 102 103 syl2an M N M + 1 mod N < N
105 82 80 100 101 104 lttrd M N M + 1 mod N 1 < N
106 39 mulid1d M N N 1 = N
107 105 106 breqtrrd M N M + 1 mod N 1 < N 1
108 22 a1i M N 1
109 14 adantl M N 0 < N
110 ltdivmul M + 1 mod N 1 1 N 0 < N M + 1 mod N 1 N < 1 M + 1 mod N 1 < N 1
111 82 108 100 109 110 syl112anc M N M + 1 mod N 1 N < 1 M + 1 mod N 1 < N 1
112 107 111 mpbird M N M + 1 mod N 1 N < 1
113 112 adantr M N ¬ N M + 1 M + 1 mod N 1 N < 1
114 nndivre M + 1 mod N 1 N M + 1 mod N 1 N
115 82 114 sylancom M N M + 1 mod N 1 N
116 flbi2 M + 1 N M + 1 mod N 1 N M + 1 N + M + 1 mod N 1 N = M + 1 N 0 M + 1 mod N 1 N M + 1 mod N 1 N < 1
117 68 115 116 syl2anc M N M + 1 N + M + 1 mod N 1 N = M + 1 N 0 M + 1 mod N 1 N M + 1 mod N 1 N < 1
118 117 adantr M N ¬ N M + 1 M + 1 N + M + 1 mod N 1 N = M + 1 N 0 M + 1 mod N 1 N M + 1 mod N 1 N < 1
119 99 113 118 mpbir2and M N ¬ N M + 1 M + 1 N + M + 1 mod N 1 N = M + 1 N
120 modval M + 1 N + M + 1 mod N = M + 1 - N M + 1 N
121 65 102 120 syl2an M N M + 1 mod N = M + 1 - N M + 1 N
122 121 oveq1d M N M + 1 mod N 1 = M + 1 - N M + 1 N - 1
123 39 69 mulcld M N N M + 1 N
124 42 38 123 sub32d M N M + 1 - 1 - N M + 1 N = M + 1 - N M + 1 N - 1
125 122 124 eqtr4d M N M + 1 mod N 1 = M + 1 - 1 - N M + 1 N
126 pncan M 1 M + 1 - 1 = M
127 36 37 126 sylancl M N M + 1 - 1 = M
128 127 oveq1d M N M + 1 - 1 - N M + 1 N = M N M + 1 N
129 125 128 eqtrd M N M + 1 mod N 1 = M N M + 1 N
130 129 oveq1d M N M + 1 mod N 1 N = M N M + 1 N N
131 36 123 39 46 divsubdird M N M N M + 1 N N = M N N M + 1 N N
132 69 39 46 divcan3d M N N M + 1 N N = M + 1 N
133 132 oveq2d M N M N N M + 1 N N = M N M + 1 N
134 130 131 133 3eqtrrd M N M N M + 1 N = M + 1 mod N 1 N
135 58 recnd M N M N
136 115 recnd M N M + 1 mod N 1 N
137 135 69 136 subaddd M N M N M + 1 N = M + 1 mod N 1 N M + 1 N + M + 1 mod N 1 N = M N
138 134 137 mpbid M N M + 1 N + M + 1 mod N 1 N = M N
139 138 adantr M N ¬ N M + 1 M + 1 N + M + 1 mod N 1 N = M N
140 139 fveq2d M N ¬ N M + 1 M + 1 N + M + 1 mod N 1 N = M N
141 119 140 eqtr3d M N ¬ N M + 1 M + 1 N = M N
142 69 71 subeq0ad M N M + 1 N M N = 0 M + 1 N = M N
143 142 adantr M N ¬ N M + 1 M + 1 N M N = 0 M + 1 N = M N
144 141 143 mpbird M N ¬ N M + 1 M + 1 N M N = 0
145 iffalse ¬ N M + 1 if N M + 1 1 0 = 0
146 145 adantl M N ¬ N M + 1 if N M + 1 1 0 = 0
147 144 146 eqtr4d M N ¬ N M + 1 M + 1 N M N = if N M + 1 1 0
148 77 147 pm2.61dan M N M + 1 N M N = if N M + 1 1 0