X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Flibrary%2Fnat%2Fiteration2.ma;h=211df69d0fa0d9941a9dcf14bebca51e1812ffda;hb=10f29fdd78ee089a9a94446207b543d33d6c851c;hp=ea306f4554a6c2c83e809dace78d034d9534bcc8;hpb=1f214ad28b490ed66602eb2d80359c01ba55ee05;p=helm.git diff --git a/helm/software/matita/library/nat/iteration2.ma b/helm/software/matita/library/nat/iteration2.ma index ea306f455..211df69d0 100644 --- a/helm/software/matita/library/nat/iteration2.ma +++ b/helm/software/matita/library/nat/iteration2.ma @@ -107,6 +107,84 @@ apply (false_to_eq_iter_p_gen); assumption. qed. +theorem or_false_to_eq_sigma_p: +\forall n,m:nat.\forall p:nat \to bool. +\forall g: nat \to nat. +n \le m \to (\forall i:nat. n \le i \to i < m \to p i = false \lor g i = O) +\to sigma_p m p g = sigma_p n p g. +intros. +unfold sigma_p. +apply or_false_eq_baseA_to_eq_iter_p_gen + [intros.reflexivity + |assumption + |assumption + ] +qed. + +theorem bool_to_nat_to_eq_sigma_p: +\forall n:nat.\forall p1,p2:nat \to bool. +\forall g1,g2: nat \to nat. +(\forall i:nat. +bool_to_nat (p1 i)*(g1 i) = bool_to_nat (p2 i)*(g2 i)) +\to sigma_p n p1 g1 = sigma_p n p2 g2. +intros.elim n + [reflexivity + |generalize in match (H n1). + apply (bool_elim ? (p1 n1));intro + [apply (bool_elim ? (p2 n1));intros + [rewrite > true_to_sigma_p_Sn + [rewrite > true_to_sigma_p_Sn + [apply eq_f2 + [simplify in H4. + rewrite > plus_n_O. + rewrite > plus_n_O in ⊢ (? ? ? %). + assumption + |assumption + ] + |assumption + ] + |assumption + ] + |rewrite > true_to_sigma_p_Sn + [rewrite > false_to_sigma_p_Sn + [change in ⊢ (? ? ? %) with (O + sigma_p n1 p2 g2). + apply eq_f2 + [simplify in H4. + rewrite > plus_n_O. + assumption + |assumption + ] + |assumption + ] + |assumption + ] + ] + |apply (bool_elim ? (p2 n1));intros + [rewrite > false_to_sigma_p_Sn + [rewrite > true_to_sigma_p_Sn + [change in ⊢ (? ? % ?) with (O + sigma_p n1 p1 g1). + apply eq_f2 + [simplify in H4. + rewrite < plus_n_O in H4. + assumption + |assumption + ] + |assumption + ] + |assumption + ] + |rewrite > false_to_sigma_p_Sn + [rewrite > false_to_sigma_p_Sn + [assumption + |assumption + ] + |assumption + ] + ] + ] + ] +qed. + theorem sigma_p2 : \forall n,m:nat. \forall p1,p2:nat \to bool. @@ -191,6 +269,20 @@ apply (eq_iter_p_gen_gh nat O plus ? ? ? g h h1 n n1 p1 p2) ] qed. +theorem eq_sigma_p_pred: +\forall n,p,g. p O = true \to +sigma_p (S n) (\lambda i.p (pred i)) (\lambda i.g(pred i)) = +plus (sigma_p n p g) (g O). +intros. +unfold sigma_p. +apply eq_iter_p_gen_pred + [assumption + |apply symmetricIntPlus + |apply associative_plus + |intros.apply sym_eq.apply plus_n_O + ] +qed. + (* monotonicity *) theorem le_sigma_p: \forall n:nat. \forall p:nat \to bool. \forall g1,g2:nat \to nat. @@ -226,6 +318,90 @@ elim n ] qed. +(* a slightly more general result *) +theorem le_sigma_p1: +\forall n:nat. \forall p1,p2:nat \to bool. \forall g1,g2:nat \to nat. +(\forall i. i < n \to +bool_to_nat (p1 i)*(g1 i) \le bool_to_nat (p2 i)*g2 i) \to +sigma_p n p1 g1 \le sigma_p n p2 g2. +intros. +generalize in match H. +elim n + [apply le_n. + |apply (bool_elim ? (p1 n1));intros + [apply (bool_elim ? (p2 n1));intros + [rewrite > true_to_sigma_p_Sn + [rewrite > true_to_sigma_p_Sn in ⊢ (? ? %) + [apply le_plus + [lapply (H2 n1) as H5 + [rewrite > H3 in H5. + rewrite > H4 in H5. + simplify in H5. + rewrite < plus_n_O in H5. + rewrite < plus_n_O in H5. + assumption + |apply le_S_S.apply le_n + ] + |apply H1.intros. + apply H2.apply le_S.assumption + ] + |assumption + ] + |assumption + ] + |rewrite > true_to_sigma_p_Sn + [rewrite > false_to_sigma_p_Sn in ⊢ (? ? %) + [change in ⊢ (? ? %) with (O + sigma_p n1 p2 g2). + apply le_plus + [lapply (H2 n1) as H5 + [rewrite > H3 in H5. + rewrite > H4 in H5. + simplify in H5. + rewrite < plus_n_O in H5. + assumption + |apply le_S_S.apply le_n + ] + |apply H1.intros. + apply H2.apply le_S.assumption + ] + |assumption + ] + |assumption + ] + ] + |apply (bool_elim ? (p2 n1));intros + [rewrite > false_to_sigma_p_Sn + [rewrite > true_to_sigma_p_Sn in ⊢ (? ? %) + [change in ⊢ (? % ?) with (O + sigma_p n1 p1 g1). + apply le_plus + [lapply (H2 n1) as H5 + [rewrite > H3 in H5. + rewrite > H4 in H5. + simplify in H5. + rewrite < plus_n_O in H5. + assumption + |apply le_S_S.apply le_n + ] + |apply H1.intros. + apply H2.apply le_S.assumption + ] + |assumption + ] + |assumption + ] + |rewrite > false_to_sigma_p_Sn + [rewrite > false_to_sigma_p_Sn in ⊢ (? ? %) + [apply H1.intros. + apply H2.apply le_S.assumption + |assumption + ] + |assumption + ] + ] + ] + ] +qed. + theorem lt_sigma_p: \forall n:nat. \forall p:nat \to bool. \forall g1,g2:nat \to nat. (\forall i. i < n \to p i = true \to g1 i \le g2 i ) \to @@ -453,32 +629,33 @@ elim n qed. theorem sigma_p_plus_1: \forall n:nat. \forall f,g:nat \to nat. -sigma_p n (\lambda b:nat. true) (\lambda a:nat.(f a) + (g a)) = -sigma_p n (\lambda b:nat. true) f + sigma_p n (\lambda b:nat. true) g. +\forall p. +sigma_p n p (\lambda a:nat.(f a) + (g a)) = +sigma_p n p f + sigma_p n p g. intros. elim n [ simplify. reflexivity -| rewrite > true_to_sigma_p_Sn - [ rewrite > (true_to_sigma_p_Sn n1 (\lambda c:nat.true) f) - [ rewrite > (true_to_sigma_p_Sn n1 (\lambda c:nat.true) g) - [ rewrite > assoc_plus in \vdash (? ? ? %). - rewrite < assoc_plus in \vdash (? ? ? (? ? %)). - rewrite < sym_plus in \vdash (? ? ? (? ? (? % ?))). - rewrite > assoc_plus in \vdash (? ? ? (? ? %)). - rewrite < assoc_plus in \vdash (? ? ? %). - apply eq_f. - assumption - | reflexivity - ] - | reflexivity - ] - | reflexivity - ] -] +| apply (bool_elim ? (p n1)); intro; + [ rewrite > true_to_sigma_p_Sn + [ rewrite > (true_to_sigma_p_Sn n1 p f) + [ rewrite > (true_to_sigma_p_Sn n1 p g) + [ rewrite > assoc_plus in \vdash (? ? ? %). + rewrite < assoc_plus in \vdash (? ? ? (? ? %)). + rewrite < sym_plus in \vdash (? ? ? (? ? (? % ?))). + rewrite > assoc_plus in \vdash (? ? ? (? ? %)). + rewrite < assoc_plus in \vdash (? ? ? %). + apply eq_f. + assumption]]] + assumption + | rewrite > false_to_sigma_p_Sn + [ rewrite > (false_to_sigma_p_Sn n1 p f) + [ rewrite > (false_to_sigma_p_Sn n1 p g) + [assumption]]] + assumption +]] qed. - theorem eq_sigma_p_sigma_p_times1 : \forall n,m:nat.\forall f:nat \to nat. sigma_p (n*m) (\lambda x:nat.true) f = sigma_p m (\lambda x:nat.true) @@ -525,7 +702,6 @@ rewrite > sym_times. apply eq_sigma_p_sigma_p_times1. qed. - theorem sigma_p_times:\forall n,m:nat. \forall f,f1,f2:nat \to bool. \forall g:nat \to nat \to nat. @@ -787,4 +963,21 @@ apply(iter_p_gen_2_eq nat O plus ? ? ? g h11 h12 h21 h22 n1 m1 n2 m2 p11 p21 p12 | assumption | assumption ] +qed. + +theorem sigma_p_sigma_p: +\forall g: nat \to nat \to nat. +\forall n,m. +\forall p11,p21:nat \to bool. +\forall p12,p22:nat \to nat \to bool. +(\forall x,y. x < n \to y < m \to + (p11 x \land p12 x y) = (p21 y \land p22 y x)) \to +sigma_p n p11 (\lambda x:nat.sigma_p m (p12 x) (\lambda y. g x y)) = +sigma_p m p21 (\lambda y:nat.sigma_p n (p22 y) (\lambda x. g x y)). +intros. +unfold sigma_p.unfold sigma_p. +apply (iter_p_gen_iter_p_gen ? ? ? sym_plus assoc_plus) + [intros.apply sym_eq.apply plus_n_O. + |assumption + ] qed. \ No newline at end of file