1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / Matita is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/Z/dirichlet_product".
17 include "nat/primes.ma".
18 include "Z/sigma_p.ma".
21 definition dirichlet_product : (nat \to Z) \to (nat \to Z) \to nat \to Z \def
22 \lambda f,g.\lambda n.
24 (\lambda d.divides_b d n) (\lambda d. (f d)*(g (div n d))).
26 (* dirichlet_product is associative only up to extensional equality *)
27 theorem associative_dirichlet_product:
28 \forall f,g,h:nat\to Z.\forall n:nat.O < n \to
29 dirichlet_product (dirichlet_product f g) h n
30 = dirichlet_product f (dirichlet_product g h) n.
32 unfold dirichlet_product.
33 unfold dirichlet_product.
35 (sigma_p (S n) (\lambda d:nat.divides_b d n)
37 .sigma_p (S n) (\lambda d1:nat.divides_b d1 d) (\lambda d1:nat.f d1*g (d/d1)*h (n/d)))))
42 (sigma_p (S x) (\lambda d1:nat.divides_b d1 x) (\lambda d1:nat.f d1*g (x/d1)*h (n/x))))
43 [apply Ztimes_sigma_pr
44 |(* hint solleva unification uncertain ?? *)
46 apply false_to_eq_sigma_p
49 apply not_divides_to_divides_b_false
50 [apply (lt_to_le_to_lt ? (S x))
51 [apply lt_O_S|assumption]
53 apply (lt_to_not_le ? ? H3).
55 [apply (divides_b_true_to_lt_O ? ? H H2).
63 (sigma_p (S n) (\lambda d:nat.divides_b d n)
65 .sigma_p (S n) (\lambda d1:nat.divides_b d1 (n/d))
66 (\lambda d1:nat.f d*g d1*h ((n/d)/d1)))))
68 (sigma_p (S n) (\lambda d:nat.divides_b d n)
70 .sigma_p (S n) (\lambda d1:nat.divides_b d1 (n/d))
71 (\lambda d1:nat.f d*g ((times d d1)/d)*h ((n/times d d1))))))
73 (\lambda d,d1.f d1*g (d/d1)*h (n/d))
74 (\lambda d,d1:nat.times d d1)
77 (\lambda d,d1:nat.d/d1)
84 (\lambda d,d1:nat.divides_b d1 d)
85 (\lambda d,d1:nat.divides_b d1 (n/d))
93 [apply divides_to_divides_b_true1
95 |apply (witness ? ? ((n/i)/j)).
96 rewrite > assoc_times.
97 rewrite > sym_times in \vdash (? ? ? (? ? %)).
98 rewrite > divides_to_div
100 rewrite > divides_to_div
102 |apply divides_b_true_to_divides.
105 |apply divides_b_true_to_divides.
109 |apply divides_to_divides_b_true
110 [apply (divides_b_true_to_lt_O ? ? H H3)
111 |apply (witness ? ? j).
117 |rewrite < sym_times.
118 rewrite > (plus_n_O (j*i)).
119 apply div_plus_times.
120 apply (divides_b_true_to_lt_O ? ? H H3)
122 |apply (le_to_lt_to_lt ? (i*(n/i)))
126 [elim (le_to_or_lt_eq ? ? (le_O_n (n/i)))
129 apply (lt_to_not_le ? ? H).
130 rewrite < (divides_to_div i n)
133 |apply divides_b_true_to_divides.
137 |apply divides_b_true_to_divides.
141 |rewrite < sym_times.
142 rewrite > divides_to_div
144 |apply divides_b_true_to_divides.
157 [apply divides_to_divides_b_true1
159 |apply (transitive_divides ? i)
160 [apply divides_b_true_to_divides.
162 |apply divides_b_true_to_divides.
166 |apply divides_to_divides_b_true
167 [apply (divides_b_true_to_lt_O i (i/j))
168 [apply (divides_b_true_to_lt_O ? ? ? H3).
170 |apply divides_to_divides_b_true1
171 [apply (divides_b_true_to_lt_O ? ? ? H3).
173 |apply (witness ? ? j).
175 apply divides_to_div.
176 apply divides_b_true_to_divides.
180 |apply (witness ? ? (n/i)).
181 apply (inj_times_l1 j)
182 [apply (divides_b_true_to_lt_O ? ? ? H4).
183 apply (divides_b_true_to_lt_O ? ? ? H3).
185 |rewrite > divides_to_div
186 [rewrite > sym_times in \vdash (? ? ? (? % ?)).
187 rewrite > assoc_times.
188 rewrite > divides_to_div
189 [rewrite > divides_to_div
191 |apply divides_b_true_to_divides.
194 |apply divides_b_true_to_divides.
197 |apply (transitive_divides ? i)
198 [apply divides_b_true_to_divides.
200 |apply divides_b_true_to_divides.
207 |rewrite < sym_times.
208 apply divides_to_div.
209 apply divides_b_true_to_divides.
216 |apply (le_to_lt_to_lt ? i)
218 apply (divides_b_true_to_lt_O ? ? ? H4).
219 apply (divides_b_true_to_lt_O ? ? ? H3).
236 rewrite > (plus_n_O (x1*x)).
237 apply div_plus_times.
238 apply (divides_b_true_to_lt_O ? ? ? H2).
244 [apply (inj_times_l1 (x*x1))
245 [rewrite > (times_n_O O).
246 apply lt_times;assumption
247 |rewrite > divides_to_div
248 [rewrite > sym_times in \vdash (? ? ? (? ? %)).
249 rewrite < assoc_times.
250 rewrite > divides_to_div
251 [rewrite > divides_to_div
253 |apply divides_b_true_to_divides.
256 |apply divides_b_true_to_divides.
259 |elim (divides_b_true_to_divides ? ? H4).
260 apply (witness ? ? n1).
261 rewrite > assoc_times.
265 apply divides_to_div.
266 apply divides_b_true_to_divides.
270 |apply (divides_b_true_to_lt_O ? ? ? H4).
271 apply (lt_times_n_to_lt x)
274 rewrite > divides_to_div
276 |apply (divides_b_true_to_divides ? ? H2).
281 |apply (divides_b_true_to_lt_O ? ? ? H2).
292 (sigma_p (S n) (\lambda d1:nat.divides_b d1 (n/x)) (\lambda d1:nat.f x*(g d1*h (n/x/d1)))))
295 |intros.apply assoc_Ztimes
298 (sigma_p (S (n/x)) (\lambda d1:nat.divides_b d1 (n/x)) (\lambda d1:nat.f x*(g d1*h (n/x/d1)))))
299 [apply false_to_eq_sigma_p
302 [apply (le_times_to_le x)
304 |rewrite > sym_times.
305 rewrite > divides_to_div
308 |apply divides_b_true_to_divides.
312 |apply (divides_b_true_to_lt_O ? ? ? H2).
316 apply not_divides_to_divides_b_false
317 [apply (trans_le ? ? ? ? H3).
321 apply (le_to_not_lt ? ? H3).
324 [apply (lt_times_n_to_lt x)
325 [apply (divides_b_true_to_lt_O ? ? ? H2).
328 rewrite > divides_to_div
330 |apply (divides_b_true_to_divides ? ? H2).
339 apply Ztimes_sigma_pl
347 definition is_one: nat \to Z \def
353 [ O \Rightarrow pos O
354 | (S q) \Rightarrow OZ]]
357 theorem is_one_OZ: \forall n. n \neq S O \to is_one n = OZ.
358 intro.apply (nat_case n)
360 |intro. apply (nat_case m)
361 [intro.apply False_ind.apply H.reflexivity
368 \forall p: nat \to bool.\forall n.sigma_p n p (\lambda m.OZ) = OZ.
371 |apply (bool_elim ? (p n1));intro
372 [rewrite > true_to_sigma_p_Sn
373 [rewrite > sym_Zplus.
374 rewrite > Zplus_z_OZ.
378 |rewrite > false_to_sigma_p_Sn
386 theorem dirichlet_product_is_one_r:
387 \forall f:nat\to Z.\forall n:nat.
388 dirichlet_product f is_one n = f n.
391 [unfold dirichlet_product.
392 rewrite > true_to_sigma_p_Sn
393 [rewrite > Ztimes_Zone_r.
394 rewrite > Zplus_z_OZ.
398 |unfold dirichlet_product.
399 rewrite > true_to_sigma_p_Sn
401 [rewrite > Ztimes_Zone_r.
402 rewrite < Zplus_z_OZ in \vdash (? ? ? %).
405 |apply (trans_eq ? ? (sigma_p (S n1)
406 (\lambda d:nat.divides_b d (S n1)) (\lambda d:nat.OZ)))
407 [apply eq_sigma_p1;intros
412 apply (lt_to_not_le ? ? H1).
413 rewrite > (times_n_SO x).
416 rewrite > (div_mod ? x) in \vdash (? % ?)
417 [rewrite > divides_to_mod_O
420 |apply (divides_b_true_to_lt_O ? ? ? H2).
422 |apply divides_b_true_to_divides.
425 |apply (divides_b_true_to_lt_O ? ? ? H2).
435 |apply divides_to_divides_b_true
443 theorem commutative_dirichlet_product: \forall f,g:nat \to Z.\forall n. O < n \to
444 dirichlet_product f g n = dirichlet_product g f n.
446 unfold dirichlet_product.
448 (sigma_p (S n) (\lambda d:nat.divides_b d n)
449 (\lambda d:nat.g (n/d) * f (n/(n/d)))))
450 [apply eq_sigma_p1;intros
455 |apply divides_b_true_to_divides.
459 |apply (eq_sigma_p_gh ? (\lambda d.(n/d)) (\lambda d.(n/d)))
461 apply divides_b_div_true;assumption
465 |apply divides_b_true_to_divides.
471 apply (divides_b_true_to_lt_O ? ? H H2)
473 apply divides_b_div_true;assumption
477 |apply divides_b_true_to_divides.
483 apply (divides_b_true_to_lt_O ? ? H H2)
488 theorem dirichlet_product_is_one_l:
489 \forall f:nat\to Z.\forall n:nat.
490 O < n \to dirichlet_product is_one f n = f n.
492 rewrite > commutative_dirichlet_product.
493 apply dirichlet_product_is_one_r.
497 theorem dirichlet_product_one_r:
498 \forall f:nat\to Z.\forall n:nat. O < n \to
499 dirichlet_product f (\lambda n.Zone) n =
500 sigma_p (S n) (\lambda d.divides_b d n) f.
502 unfold dirichlet_product.
503 apply eq_sigma_p;intros
505 |simplify in \vdash (? ? (? ? %) ?).
510 theorem dirichlet_product_one_l:
511 \forall f:nat\to Z.\forall n:nat. O < n \to
512 dirichlet_product (\lambda n.Zone) f n =
513 sigma_p (S n) (\lambda d.divides_b d n) f.
515 rewrite > commutative_dirichlet_product
516 [apply dirichlet_product_one_r.