Metamath Proof Explorer


Theorem digit1

Description: Two ways to express the K th digit in the decimal expansion of a number A (when base B = 1 0 ). K = 1 corresponds to the first digit after the decimal point. (Contributed by NM, 3-Jan-2009)

Ref Expression
Assertion digit1 A B K B K A mod B = B K A mod B K B B K 1 A mod B K

Proof

Step Hyp Ref Expression
1 digit2 A B K B K A mod B = B K A B B K 1 A
2 1 3coml B K A B K A mod B = B K A B B K 1 A
3 2 3expa B K A B K A mod B = B K A B B K 1 A
4 3 oveq1d B K A B K A mod B mod B K = B K A B B K 1 A mod B K
5 nnre B B
6 nnnn0 K K 0
7 reexpcl B K 0 B K
8 5 6 7 syl2an B K B K
9 remulcl B K A B K A
10 8 9 sylan B K A B K A
11 reflcl B K A B K A
12 10 11 syl B K A B K A
13 nnrp B B +
14 13 ad2antrr B K A B +
15 12 14 modcld B K A B K A mod B
16 nnexpcl B K 0 B K
17 6 16 sylan2 B K B K
18 17 nnrpd B K B K +
19 18 adantr B K A B K +
20 modge0 B K A B + 0 B K A mod B
21 12 14 20 syl2anc B K A 0 B K A mod B
22 5 ad2antrr B K A B
23 8 adantr B K A B K
24 modlt B K A B + B K A mod B < B
25 12 14 24 syl2anc B K A B K A mod B < B
26 nncn B B
27 exp1 B B 1 = B
28 26 27 syl B B 1 = B
29 28 adantr B K B 1 = B
30 5 adantr B K B
31 nnge1 B 1 B
32 31 adantr B K 1 B
33 simpr B K K
34 nnuz = 1
35 33 34 eleqtrdi B K K 1
36 leexp2a B 1 B K 1 B 1 B K
37 30 32 35 36 syl3anc B K B 1 B K
38 29 37 eqbrtrrd B K B B K
39 38 adantr B K A B B K
40 15 22 23 25 39 ltletrd B K A B K A mod B < B K
41 modid B K A mod B B K + 0 B K A mod B B K A mod B < B K B K A mod B mod B K = B K A mod B
42 15 19 21 40 41 syl22anc B K A B K A mod B mod B K = B K A mod B
43 simpll B K A B
44 nnm1nn0 K K 1 0
45 reexpcl B K 1 0 B K 1
46 5 44 45 syl2an B K B K 1
47 remulcl B K 1 A B K 1 A
48 46 47 sylan B K A B K 1 A
49 nnexpcl B K 1 0 B K 1
50 44 49 sylan2 B K B K 1
51 50 adantr B K A B K 1
52 modmulnn B B K 1 A B K 1 B B K 1 A mod B B K 1 B B K 1 A mod B B K 1
53 43 48 51 52 syl3anc B K A B B K 1 A mod B B K 1 B B K 1 A mod B B K 1
54 expm1t B K B K = B K 1 B
55 expcl B K 1 0 B K 1
56 44 55 sylan2 B K B K 1
57 simpl B K B
58 56 57 mulcomd B K B K 1 B = B B K 1
59 54 58 eqtrd B K B K = B B K 1
60 26 59 sylan B K B K = B B K 1
61 60 adantr B K A B K = B B K 1
62 61 oveq2d B K A B B K 1 A mod B K = B B K 1 A mod B B K 1
63 61 oveq1d B K A B K A = B B K 1 A
64 26 ad2antrr B K A B
65 26 44 55 syl2an B K B K 1
66 65 adantr B K A B K 1
67 recn A A
68 67 adantl B K A A
69 64 66 68 mulassd B K A B B K 1 A = B B K 1 A
70 63 69 eqtrd B K A B K A = B B K 1 A
71 70 fveq2d B K A B K A = B B K 1 A
72 71 61 oveq12d B K A B K A mod B K = B B K 1 A mod B B K 1
73 53 62 72 3brtr4d B K A B B K 1 A mod B K B K A mod B K
74 reflcl B K 1 A B K 1 A
75 48 74 syl B K A B K 1 A
76 remulcl B B K 1 A B B K 1 A
77 22 75 76 syl2anc B K A B B K 1 A
78 modsubdir B K A B B K 1 A B K + B B K 1 A mod B K B K A mod B K B K A B B K 1 A mod B K = B K A mod B K B B K 1 A mod B K
79 12 77 19 78 syl3anc B K A B B K 1 A mod B K B K A mod B K B K A B B K 1 A mod B K = B K A mod B K B B K 1 A mod B K
80 73 79 mpbid B K A B K A B B K 1 A mod B K = B K A mod B K B B K 1 A mod B K
81 4 42 80 3eqtr3d B K A B K A mod B = B K A mod B K B B K 1 A mod B K
82 81 3impa B K A B K A mod B = B K A mod B K B B K 1 A mod B K
83 82 3comr A B K B K A mod B = B K A mod B K B B K 1 A mod B K