Metamath Proof Explorer


Theorem quoremz

Description: Quotient and remainder of an integer divided by a positive integer. TODO - is this really needed for anything? Should we use mod to simplify it? Remark (AV): This is a special case of divalg . (Contributed by NM, 14-Aug-2008)

Ref Expression
Hypotheses quorem.1 Q = A B
quorem.2 R = A B Q
Assertion quoremz A B Q R 0 R < B A = B Q + R

Proof

Step Hyp Ref Expression
1 quorem.1 Q = A B
2 quorem.2 R = A B Q
3 zre A A
4 3 adantr A B A
5 nnre B B
6 5 adantl A B B
7 nnne0 B B 0
8 7 adantl A B B 0
9 4 6 8 redivcld A B A B
10 9 flcld A B A B
11 1 10 eqeltrid A B Q
12 11 zcnd A B Q
13 nncn B B
14 13 adantl A B B
15 12 14 8 divcan3d A B B Q B = Q
16 flle A B A B A B
17 9 16 syl A B A B A B
18 1 17 eqbrtrid A B Q A B
19 15 18 eqbrtrd A B B Q B A B
20 nnz B B
21 20 adantl A B B
22 21 11 zmulcld A B B Q
23 22 zred A B B Q
24 nngt0 B 0 < B
25 24 adantl A B 0 < B
26 lediv1 B Q A B 0 < B B Q A B Q B A B
27 23 4 6 25 26 syl112anc A B B Q A B Q B A B
28 19 27 mpbird A B B Q A
29 simpl A B A
30 znn0sub B Q A B Q A A B Q 0
31 22 29 30 syl2anc A B B Q A A B Q 0
32 28 31 mpbid A B A B Q 0
33 2 32 eqeltrid A B R 0
34 1 oveq2i A B Q = A B A B
35 fraclt1 A B A B A B < 1
36 9 35 syl A B A B A B < 1
37 34 36 eqbrtrid A B A B Q < 1
38 2 oveq1i R B = A B Q B
39 zcn A A
40 39 adantr A B A
41 22 zcnd A B B Q
42 13 7 jca B B B 0
43 42 adantl A B B B 0
44 divsubdir A B Q B B 0 A B Q B = A B B Q B
45 40 41 43 44 syl3anc A B A B Q B = A B B Q B
46 15 oveq2d A B A B B Q B = A B Q
47 45 46 eqtrd A B A B Q B = A B Q
48 38 47 eqtrid A B R B = A B Q
49 13 7 dividd B B B = 1
50 49 adantl A B B B = 1
51 37 48 50 3brtr4d A B R B < B B
52 33 nn0red A B R
53 ltdiv1 R B B 0 < B R < B R B < B B
54 52 6 6 25 53 syl112anc A B R < B R B < B B
55 51 54 mpbird A B R < B
56 2 oveq2i B Q + R = B Q + A - B Q
57 41 40 pncan3d A B B Q + A - B Q = A
58 56 57 eqtr2id A B A = B Q + R
59 55 58 jca A B R < B A = B Q + R
60 11 33 59 jca31 A B Q R 0 R < B A = B Q + R