]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/library/nat/iteration2.ma
Further simplifications to the main theorem about Euler's totient function.
[helm.git] / helm / software / matita / library / nat / iteration2.ma
index 4f0238498c500d0409c25e3d73196e6d3704dd31..e00bb442089752014f6ed9c630bf7ad445b867d9 100644 (file)
@@ -16,13 +16,13 @@ set "baseuri" "cic:/matita/nat/iteration2".
 
 include "nat/primes.ma".
 include "nat/ord.ma".
-include "nat/generic_sigma_p.ma".
+include "nat/generic_iter_p.ma".
 include "nat/count.ma".(*necessary just to use bool_to_nat and bool_to_nat_andb*)
 
 
 (* sigma_p on nautral numbers is a specialization of sigma_p_gen *)
 definition sigma_p: nat \to (nat \to bool) \to (nat \to nat) \to nat \def
-\lambda n, p, g. (sigma_p_gen n p nat g O plus).
+\lambda n, p, g. (iter_p_gen n p nat g O plus).
 
 theorem symmetricIntPlus: symmetric nat plus.
 change with (\forall a,b:nat. (plus a b) = (plus b a)).
@@ -40,7 +40,7 @@ p n = true \to sigma_p (S n) p g =
 (g n)+(sigma_p n p g).
 intros.
 unfold sigma_p.
-apply true_to_sigma_p_Sn_gen.
+apply true_to_iter_p_gen_Sn.
 assumption.
 qed.
    
@@ -49,10 +49,9 @@ theorem false_to_sigma_p_Sn:
 p n = false \to sigma_p (S n) p g = sigma_p n p g.
 intros.
 unfold sigma_p.
-apply false_to_sigma_p_Sn_gen.
+apply false_to_iter_p_gen_Sn.
 assumption.
-
-qed.
+qed.  
 
 theorem eq_sigma_p: \forall p1,p2:nat \to bool.
 \forall g1,g2: nat \to nat.\forall n.
@@ -61,7 +60,7 @@ theorem eq_sigma_p: \forall p1,p2:nat \to bool.
 sigma_p n p1 g1 = sigma_p n p2 g2.
 intros.
 unfold sigma_p.
-apply eq_sigma_p_gen;
+apply eq_iter_p_gen;
   assumption.
 qed.
 
@@ -72,7 +71,7 @@ theorem eq_sigma_p1: \forall p1,p2:nat \to bool.
 sigma_p n p1 g1 = sigma_p n p2 g2.
 intros.
 unfold sigma_p.
-apply eq_sigma_p1_gen;
+apply eq_iter_p_gen1;
   assumption.
 qed.
 
@@ -80,7 +79,7 @@ theorem sigma_p_false:
 \forall g: nat \to nat.\forall n.sigma_p n (\lambda x.false) g = O.
 intros.
 unfold sigma_p.
-apply sigma_p_false_gen.
+apply iter_p_gen_false.
 qed.
 
 theorem sigma_p_plus: \forall n,k:nat.\forall p:nat \to bool.
@@ -89,7 +88,7 @@ sigma_p (k+n) p g
 = sigma_p k (\lambda x.p (x+n)) (\lambda x.g (x+n)) + sigma_p n p g.
 intros.
 unfold sigma_p.
-apply (sigma_p_plusA_gen nat n k p g O plus)
+apply (iter_p_gen_plusA nat n k p g O plus)
 [ apply symmetricIntPlus.
 | intros.
   apply sym_eq.
@@ -104,7 +103,7 @@ theorem false_to_eq_sigma_p: \forall n,m:nat.n \le m \to
 p i = false) \to sigma_p m p g = sigma_p n p g.
 intros.
 unfold sigma_p.
-apply (false_to_eq_sigma_p_gen);
+apply (false_to_eq_iter_p_gen);
   assumption.
 qed.
 
@@ -119,7 +118,7 @@ sigma_p n p1
   (\lambda x.sigma_p m p2 (g x)).
 intros.
 unfold sigma_p.
-apply (sigma_p2_gen n m p1 p2 nat g O plus)
+apply (iter_p_gen2 n m p1 p2 nat g O plus)
 [ apply symmetricIntPlus
 | apply associative_plus
 | intros.
@@ -134,13 +133,13 @@ theorem sigma_p2' :
 \forall p2:nat \to nat \to bool.
 \forall g: nat \to nat \to nat.
 sigma_p (n*m) 
-  (\lambda x.andb (p1 (div x m)) (p2 (div x m) (mod x m))) 
+  (\lambda x.andb (p1 (div x m)) (p2 (div x m) (mod x  m))) 
   (\lambda x.g (div x m) (mod x m)) =
 sigma_p n p1 
   (\lambda x.sigma_p m (p2 x) (g x)).
 intros.
 unfold sigma_p.
-apply (sigma_p2_gen' n m p1 p2 nat g O plus)
+apply (iter_p_gen2' n m p1 p2 nat g O plus)
 [ apply symmetricIntPlus
 | apply associative_plus
 | intros.
@@ -154,7 +153,7 @@ lemma sigma_p_gi: \forall g: nat \to nat.
 sigma_p n p g = g i + sigma_p n (\lambda x. andb (p x) (notb (eqb x i))) g.
 intros.
 unfold sigma_p.
-apply (sigma_p_gi_gen)
+apply (iter_p_gen_gi)
 [ apply symmetricIntPlus
 | apply associative_plus
 | intros.
@@ -174,10 +173,10 @@ theorem eq_sigma_p_gh:
 (\forall j. j < n1 \to p2 j = true \to p1 (h1 j) = true) \to
 (\forall j. j < n1 \to p2 j = true \to h (h1 j) = j) \to 
 (\forall j. j < n1 \to p2 j = true \to h1 j < n) \to 
-sigma_p n p1 (\lambda x.g(h x)) = sigma_p n1 (\lambda x.p2 x) g.
+sigma_p n p1 (\lambda x.g(h x)) = sigma_p n1 p2 g.
 intros.
 unfold sigma_p.
-apply (eq_sigma_p_gh_gen nat O plus ? ? ? g h h1 n n1 p1 p2)
+apply (eq_iter_p_gen_gh nat O plus ? ? ? g h h1 n n1 p1 p2)
 [ apply symmetricIntPlus
 | apply associative_plus
 | intros.
@@ -201,7 +200,7 @@ sigma_p (S n) (\lambda x.divides_b x n)
   (\lambda x.sigma_p (S m) (\lambda y.true) (\lambda y.g (x*(exp p y)))).
 intros.
 unfold sigma_p.
-apply (sigma_p_divides_gen nat O plus n m p ? ? ? g)
+apply (iter_p_gen_divides nat O plus n m p ? ? ? g)
 [ assumption
 | assumption
 | assumption
@@ -216,7 +215,7 @@ qed.
 theorem distributive_times_plus_sigma_p: \forall n,k:nat. \forall p:nat \to bool. \forall g:nat \to nat.
 k*(sigma_p n p g) = sigma_p n p (\lambda i:nat.k * (g i)).
 intros.
-apply (distributive_times_plus_sigma_p_generic nat plus O times n k p g)
+apply (distributive_times_plus_iter_p_gen nat plus O times n k p g)
 [ apply symmetricIntPlus
 | apply associative_plus
 | intros.
@@ -581,3 +580,35 @@ rewrite > (S_pred ((S n)*(S m))) in \vdash (? ? (? % ? ?) ?)
 | apply lt_O_times_S_S
 ]
 qed.
+
+theorem sigma_p_knm: 
+\forall g: nat \to nat.
+\forall h2:nat \to nat \to nat.
+\forall h11,h12:nat \to nat. 
+\forall k,n,m.
+\forall p1,p21:nat \to bool.
+\forall p22:nat \to nat \to bool.
+(\forall x. x < k \to p1 x = true \to 
+p21 (h11 x) = true \land p22 (h11 x) (h12 x) = true
+\land h2 (h11 x) (h12 x) = x 
+\land (h11 x) < n \land (h12 x) < m) \to
+(\forall i,j. i < n \to j < m \to p21 i = true \to p22 i j = true \to 
+p1 (h2 i j) = true \land 
+h11 (h2 i j) = i \land h12 (h2 i j) = j
+\land h2 i j < k) \to
+sigma_p k p1 g=
+sigma_p n p21 (\lambda x:nat.sigma_p m (p22 x) (\lambda y. g (h2 x y))).
+intros.
+unfold sigma_p.
+unfold sigma_p in \vdash (? ? ? (? ? ? ? (\lambda x:?.%) ? ?)).
+apply iter_p_gen_knm
+  [apply symmetricIntPlus
+  |apply associative_plus
+  |intro.rewrite < plus_n_O.reflexivity
+  |exact h11
+  |exact h12
+  |assumption
+  |assumption
+  ]
+qed.
+  
\ No newline at end of file