1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "nat/totient.ma".
16 include "nat/iteration2.ma".
17 include "nat/gcd_properties1.ma".
19 (* This file contains the proof of the following theorem about Euler's totient
22 The sum of the applications of Phi function over the divisor of a natural
23 number n is equal to n
26 (*simple auxiliary properties*)
27 theorem lt_O_to_divides_to_lt_O_div:
29 O \lt b \to a \divides b \to O \lt (b/a).
31 apply (O_lt_times_to_O_lt ? a).
32 rewrite > (divides_to_div a b);
37 theorem sigma_p_Sn_divides_b_totient_n: \forall n. O \lt n \to sigma_p (S n) (\lambda d.divides_b d n) totient = n.
41 (sigma_p (S n) (\lambda d:nat.divides_b d n)
42 (\lambda d:nat.sigma_p (S n) (\lambda m:nat.andb (leb (S m) d) (eqb (gcd m d) (S O))) (\lambda m:nat.S O))))
49 (sigma_p x (\lambda m:nat.leb (S m) x\land eqb (gcd m x) (S O)) (\lambda m:nat.S O)))
50 [ apply false_to_eq_sigma_p
54 rewrite > lt_to_leb_false
62 rewrite > le_to_leb_true
71 | apply (trans_eq ? ? (sigma_p n (\lambda x.true) (\lambda x.S O)))
76 (\lambda p. n / (gcd p n))
77 (\lambda p. p / (gcd p n))
79 [ cut (O \lt (gcd x n))
84 [ apply divides_to_divides_b_true
85 [ apply (O_lt_times_to_O_lt ? (gcd x n)).
86 rewrite > (divides_to_div (gcd x n) n)
88 | apply (divides_gcd_m)
91 apply (divides_times_to_divides_div_gcd).
92 apply (witness n (x * n) x).
93 apply (symmetric_times x n)
95 | apply (true_to_true_to_andb_true)
96 [ apply (le_to_leb_true).
97 change with (x/(gcd x n) \lt n/(gcd x n)).
98 apply (lt_times_n_to_lt (gcd x n) ? ?)
100 | rewrite > (divides_to_div (gcd x n) x)
101 [ rewrite > (divides_to_div (gcd x n) n)
103 | apply divides_gcd_m
105 | apply divides_gcd_n
108 | apply eq_to_eqb_true.
109 rewrite > (eq_gcd_div_div_div_gcd x n (gcd x n))
110 [ apply (div_n_n (gcd x n) Hcut)
112 | apply divides_gcd_n
113 | apply divides_gcd_m
117 | apply (inj_times_l1 (n/(gcd x n)))
118 [ apply lt_O_to_divides_to_lt_O_div
120 | apply divides_gcd_m
122 | rewrite > associative_times.
123 rewrite > (divides_to_div (n/(gcd x n)) n)
124 [ rewrite > sym_times.
125 rewrite > (divides_to_eq_times_div_div_times x)
126 [ apply (inj_times_l1 (gcd x n) Hcut).
127 rewrite > (divides_to_div (gcd x n) (x * n))
128 [ rewrite > assoc_times.
129 rewrite > (divides_to_div (gcd x n) x)
131 | apply divides_gcd_n
133 | apply (trans_divides ? x)
134 [ apply divides_gcd_n
135 | apply (witness ? ? n).
140 | apply divides_gcd_m
142 | apply (witness ? ? (gcd x n)).
143 rewrite > divides_to_div
145 | apply divides_gcd_m
150 | apply (le_to_lt_to_lt ? n)
153 | change with ((S n) \le (S n)).
157 | apply (le_to_lt_to_lt ? x)
160 | apply (trans_lt ? n ?)
162 | change with ((S n) \le (S n)).
167 | apply (divides_to_lt_O ? n)
169 | apply divides_gcd_m
174 [ cut ((gcd j i) = (S O) )
175 [ cut ((gcd (j*(n/i)) n) = n/i)
185 rewrite < divides_to_eq_times_div_div_times
189 | apply lt_O_to_divides_to_lt_O_div;
192 | apply lt_O_to_divides_to_lt_O_div;
197 | rewrite < (divides_to_div i n) in \vdash (? ? %)
198 [ rewrite > sym_times.
200 [ apply lt_O_to_divides_to_lt_O_div;
207 | rewrite < (divides_to_div i n) in \vdash (? ? (? ? %) ?)
208 [ rewrite > (sym_times j).
209 rewrite > times_n_SO in \vdash (? ? ? %).
211 apply eq_gcd_times_times_times_gcd
215 | apply eqb_true_to_eq.
216 apply (andb_true_true_r (leb (S j) i)).
219 | change with ((S j) \le i).
220 cut((leb (S j) i) = true)
223 [ true \Rightarrow ((S j) \leq i)
224 | false \Rightarrow ((S j) \nleq i)]
228 | apply (andb_true_true (leb (S j) i) (eqb (gcd j i) (S O))).
232 | apply (divides_b_true_to_divides).
236 | apply (sigma_p_true).