(* *)
(**************************************************************************)
-set "baseuri" "cic:/matita/Z/sigma_p.ma".
-
include "Z/times.ma".
include "nat/primes.ma".
include "nat/ord.ma".
+include "nat/generic_iter_p.ma".
-let rec sigma_p n p (g:nat \to Z) \def
- match n with
- [ O \Rightarrow OZ
- | (S k) \Rightarrow
- match p k with
- [true \Rightarrow (g k)+(sigma_p k p g)
- |false \Rightarrow sigma_p k p g]
- ].
+(* sigma_p in Z is a specialization of iter_p_gen *)
+definition sigma_p: nat \to (nat \to bool) \to (nat \to Z) \to Z \def
+\lambda n, p, g. (iter_p_gen n p Z g OZ Zplus).
+theorem symmetricZPlus: symmetric Z Zplus.
+change with (\forall a,b:Z. (Zplus a b) = (Zplus b a)).
+intros.
+rewrite > sym_Zplus.
+reflexivity.
+qed.
+
theorem true_to_sigma_p_Sn:
\forall n:nat. \forall p:nat \to bool. \forall g:nat \to Z.
p n = true \to sigma_p (S n) p g =
(g n)+(sigma_p n p g).
-intros.simplify.
-rewrite > H.reflexivity.
+intros.
+unfold sigma_p.
+apply true_to_iter_p_gen_Sn.
+assumption.
qed.
theorem false_to_sigma_p_Sn:
\forall n:nat. \forall p:nat \to bool. \forall g:nat \to Z.
p n = false \to sigma_p (S n) p g = sigma_p n p g.
-intros.simplify.
-rewrite > H.reflexivity.
+intros.
+unfold sigma_p.
+apply false_to_iter_p_gen_Sn.
+assumption.
qed.
theorem eq_sigma_p: \forall p1,p2:nat \to bool.
(\forall x. x < n \to p1 x = p2 x) \to
(\forall x. x < n \to g1 x = g2 x) \to
sigma_p n p1 g1 = sigma_p n p2 g2.
-intros 5.elim n
- [reflexivity
- |apply (bool_elim ? (p1 n1))
- [intro.
- rewrite > (true_to_sigma_p_Sn ? ? ? H3).
- rewrite > true_to_sigma_p_Sn
- [apply eq_f2
- [apply H2.apply le_n.
- |apply H
- [intros.apply H1.apply le_S.assumption
- |intros.apply H2.apply le_S.assumption
- ]
- ]
- |rewrite < H3.apply sym_eq.apply H1.apply le_n
- ]
- |intro.
- rewrite > (false_to_sigma_p_Sn ? ? ? H3).
- rewrite > false_to_sigma_p_Sn
- [apply H
- [intros.apply H1.apply le_S.assumption
- |intros.apply H2.apply le_S.assumption
- ]
- |rewrite < H3.apply sym_eq.apply H1.apply le_n
- ]
- ]
- ]
+intros.
+unfold sigma_p.
+apply eq_iter_p_gen;
+ assumption.
qed.
theorem eq_sigma_p1: \forall p1,p2:nat \to bool.
(\forall x. x < n \to p1 x = p2 x) \to
(\forall x. x < n \to p1 x = true \to g1 x = g2 x) \to
sigma_p n p1 g1 = sigma_p n p2 g2.
-intros 5.
-elim n
- [reflexivity
- |apply (bool_elim ? (p1 n1))
- [intro.
- rewrite > (true_to_sigma_p_Sn ? ? ? H3).
- rewrite > true_to_sigma_p_Sn
- [apply eq_f2
- [apply H2
- [apply le_n|assumption]
- |apply H
- [intros.apply H1.apply le_S.assumption
- |intros.apply H2
- [apply le_S.assumption|assumption]
- ]
- ]
- |rewrite < H3.apply sym_eq.apply H1.apply le_n
- ]
- |intro.
- rewrite > (false_to_sigma_p_Sn ? ? ? H3).
- rewrite > false_to_sigma_p_Sn
- [apply H
- [intros.apply H1.apply le_S.assumption
- |intros.apply H2
- [apply le_S.assumption|assumption]
- ]
- |rewrite < H3.apply sym_eq.apply H1.apply le_n
- ]
- ]
- ]
+intros.
+unfold sigma_p.
+apply eq_iter_p_gen1;
+ assumption.
qed.
theorem sigma_p_false:
\forall g: nat \to Z.\forall n.sigma_p n (\lambda x.false) g = O.
intros.
-elim n[reflexivity|simplify.assumption]
+unfold sigma_p.
+apply iter_p_gen_false.
qed.
theorem sigma_p_plus: \forall n,k:nat.\forall p:nat \to bool.
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.
-elim k
- [reflexivity
- |apply (bool_elim ? (p (n1+n)))
- [intro.
- simplify in \vdash (? ? (? % ? ?) ?).
- rewrite > (true_to_sigma_p_Sn ? ? ? H1).
- rewrite > (true_to_sigma_p_Sn n1 (\lambda x.p (x+n)) ? H1).
- rewrite > assoc_Zplus.
- rewrite < H.reflexivity
- |intro.
- simplify in \vdash (? ? (? % ? ?) ?).
- rewrite > (false_to_sigma_p_Sn ? ? ? H1).
- rewrite > (false_to_sigma_p_Sn n1 (\lambda x.p (x+n)) ? H1).
- assumption.
- ]
- ]
+unfold sigma_p.
+apply (iter_p_gen_plusA Z n k p g OZ Zplus)
+[ apply symmetricZPlus.
+| intros.
+ apply cic:/matita/Z/plus/Zplus_z_OZ.con
+| apply associative_Zplus
+]
qed.
theorem false_to_eq_sigma_p: \forall n,m:nat.n \le m \to
\forall p:nat \to bool.
\forall g: nat \to Z. (\forall i:nat. n \le i \to i < m \to
p i = false) \to sigma_p m p g = sigma_p n p g.
-intros 5.
-elim H
- [reflexivity
- |simplify.
- rewrite > H3
- [simplify.
- apply H2.
- intros.
- apply H3[apply H4|apply le_S.assumption]
- |assumption
- |apply le_n
- ]
- ]
+intros.
+unfold sigma_p.
+apply (false_to_eq_iter_p_gen);
+ assumption.
qed.
theorem sigma_p2 :
sigma_p n p1
(\lambda x.sigma_p m p2 (g x)).
intros.
-elim n
- [simplify.reflexivity
- |apply (bool_elim ? (p1 n1))
- [intro.
- rewrite > (true_to_sigma_p_Sn ? ? ? H1).
- simplify in \vdash (? ? (? % ? ?) ?);
- rewrite > sigma_p_plus.
- rewrite < H.
- apply eq_f2
- [apply eq_sigma_p
- [intros.
- rewrite > sym_plus.
- rewrite > (div_plus_times ? ? ? H2).
- rewrite > (mod_plus_times ? ? ? H2).
- rewrite > H1.
- simplify.reflexivity
- |intros.
- rewrite > sym_plus.
- rewrite > (div_plus_times ? ? ? H2).
- rewrite > (mod_plus_times ? ? ? H2).
- rewrite > H1.
- simplify.reflexivity.
- ]
- |reflexivity
- ]
- |intro.
- rewrite > (false_to_sigma_p_Sn ? ? ? H1).
- simplify in \vdash (? ? (? % ? ?) ?);
- rewrite > sigma_p_plus.
- rewrite > H.
- apply (trans_eq ? ? (O+(sigma_p n1 p1 (\lambda x:nat.sigma_p m p2 (g x)))))
- [apply eq_f2
- [rewrite > (eq_sigma_p ? (\lambda x.false) ? (\lambda x:nat.g ((x+n1*m)/m) ((x+n1*m)\mod m)))
- [apply sigma_p_false
- |intros.
- rewrite > sym_plus.
- rewrite > (div_plus_times ? ? ? H2).
- rewrite > (mod_plus_times ? ? ? H2).
- rewrite > H1.
- simplify.reflexivity
- |intros.reflexivity.
- ]
- |reflexivity
- ]
- |reflexivity
- ]
- ]
- ]
+unfold sigma_p.
+apply (iter_p_gen2 n m p1 p2 Z g OZ Zplus)
+[ apply symmetricZPlus
+| apply associative_Zplus
+| intros.
+ apply Zplus_z_OZ
+]
qed.
(* a stronger, dependent version, required e.g. for dirichlet product *)
+
theorem sigma_p2' :
\forall n,m:nat.
\forall p1:nat \to bool.
sigma_p n p1
(\lambda x.sigma_p m (p2 x) (g x)).
intros.
-elim n
- [simplify.reflexivity
- |apply (bool_elim ? (p1 n1))
- [intro.
- rewrite > (true_to_sigma_p_Sn ? ? ? H1).
- simplify in \vdash (? ? (? % ? ?) ?);
- rewrite > sigma_p_plus.
- rewrite < H.
- apply eq_f2
- [apply eq_sigma_p
- [intros.
- rewrite > sym_plus.
- rewrite > (div_plus_times ? ? ? H2).
- rewrite > (mod_plus_times ? ? ? H2).
- rewrite > H1.
- simplify.reflexivity
- |intros.
- rewrite > sym_plus.
- rewrite > (div_plus_times ? ? ? H2).
- rewrite > (mod_plus_times ? ? ? H2).
- rewrite > H1.
- simplify.reflexivity.
- ]
- |reflexivity
- ]
- |intro.
- rewrite > (false_to_sigma_p_Sn ? ? ? H1).
- simplify in \vdash (? ? (? % ? ?) ?);
- rewrite > sigma_p_plus.
- rewrite > H.
- apply (trans_eq ? ? (O+(sigma_p n1 p1 (\lambda x:nat.sigma_p m (p2 x) (g x)))))
- [apply eq_f2
- [rewrite > (eq_sigma_p ? (\lambda x.false) ? (\lambda x:nat.g ((x+n1*m)/m) ((x+n1*m)\mod m)))
- [apply sigma_p_false
- |intros.
- rewrite > sym_plus.
- rewrite > (div_plus_times ? ? ? H2).
- rewrite > (mod_plus_times ? ? ? H2).
- rewrite > H1.
- simplify.reflexivity
- |intros.reflexivity.
- ]
- |reflexivity
- ]
- |reflexivity
- ]
- ]
- ]
+unfold sigma_p.
+apply (iter_p_gen2' n m p1 p2 Z g OZ Zplus)
+[ apply symmetricZPlus
+| apply associative_Zplus
+| intros.
+ apply Zplus_z_OZ
+]
qed.
lemma sigma_p_gi: \forall g: nat \to Z.
\forall n,i.\forall p:nat \to bool.i < n \to p i = true \to
sigma_p n p g = g i + sigma_p n (\lambda x. andb (p x) (notb (eqb x i))) g.
-intros 2.
-elim n
- [apply False_ind.
- apply (not_le_Sn_O i).
- assumption
- |apply (bool_elim ? (p n1));intro
- [elim (le_to_or_lt_eq i n1)
- [rewrite > true_to_sigma_p_Sn
- [rewrite > true_to_sigma_p_Sn
- [rewrite < assoc_Zplus.
- rewrite < sym_Zplus in \vdash (? ? ? (? % ?)).
- rewrite > assoc_Zplus.
- apply eq_f2
- [reflexivity
- |apply H[assumption|assumption]
- ]
- |rewrite > H3.simplify.
- change with (notb (eqb n1 i) = notb false).
- apply eq_f.
- apply not_eq_to_eqb_false.
- unfold Not.intro.
- apply (lt_to_not_eq ? ? H4).
- apply sym_eq.assumption
- ]
- |assumption
- ]
- |rewrite > true_to_sigma_p_Sn
- [rewrite > H4.
- apply eq_f2
- [reflexivity
- |rewrite > false_to_sigma_p_Sn
- [apply eq_sigma_p
- [intros.
- elim (p x)
- [simplify.
- change with (notb false = notb (eqb x n1)).
- apply eq_f.
- apply sym_eq.
- apply not_eq_to_eqb_false.
- apply (lt_to_not_eq ? ? H5)
- |reflexivity
- ]
- |intros.reflexivity
- ]
- |rewrite > H3.
- rewrite > (eq_to_eqb_true ? ? (refl_eq ? n1)).
- reflexivity
- ]
- ]
- |assumption
- ]
- |apply le_S_S_to_le.assumption
- ]
- |rewrite > false_to_sigma_p_Sn
- [elim (le_to_or_lt_eq i n1)
- [rewrite > false_to_sigma_p_Sn
- [apply H[assumption|assumption]
- |rewrite > H3.reflexivity
- ]
- |apply False_ind.
- apply not_eq_true_false.
- rewrite < H2.
- rewrite > H4.
- assumption
- |apply le_S_S_to_le.assumption
- ]
- |assumption
- ]
- ]
- ]
+intros.
+unfold sigma_p.
+apply (iter_p_gen_gi)
+[ apply symmetricZPlus
+| apply associative_Zplus
+| intros.
+ apply Zplus_z_OZ
+| assumption
+| assumption
+]
qed.
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.
-intros 4.
-elim n
- [generalize in match H5.
- elim n1
- [reflexivity
- |apply (bool_elim ? (p2 n2));intro
- [apply False_ind.
- apply (not_le_Sn_O (h1 n2)).
- apply H7
- [apply le_n|assumption]
- |rewrite > false_to_sigma_p_Sn
- [apply H6.
- intros.
- apply H7[apply le_S.apply H9|assumption]
- |assumption
- ]
- ]
- ]
- |apply (bool_elim ? (p1 n1));intro
- [rewrite > true_to_sigma_p_Sn
- [rewrite > (sigma_p_gi g n2 (h n1))
- [apply eq_f2
- [reflexivity
- |apply H
- [intros.
- rewrite > H1
- [simplify.
- change with ((\not eqb (h i) (h n1))= \not false).
- apply eq_f.
- apply not_eq_to_eqb_false.
- unfold Not.intro.
- apply (lt_to_not_eq ? ? H8).
- rewrite < H2
- [rewrite < (H2 n1)
- [apply eq_f.assumption|apply le_n|assumption]
- |apply le_S.assumption
- |assumption
- ]
- |apply le_S.assumption
- |assumption
- ]
- |intros.
- apply H2[apply le_S.assumption|assumption]
- |intros.
- apply H3[apply le_S.assumption|assumption]
- |intros.
- apply H4
- [assumption
- |generalize in match H9.
- elim (p2 j)
- [reflexivity|assumption]
- ]
- |intros.
- apply H5
- [assumption
- |generalize in match H9.
- elim (p2 j)
- [reflexivity|assumption]
- ]
- |intros.
- elim (le_to_or_lt_eq (h1 j) n1)
- [assumption
- |generalize in match H9.
- elim (p2 j)
- [simplify in H11.
- absurd (j = (h n1))
- [rewrite < H10.
- rewrite > H5
- [reflexivity|assumption|autobatch]
- |apply eqb_false_to_not_eq.
- generalize in match H11.
- elim (eqb j (h n1))
- [apply sym_eq.assumption|reflexivity]
- ]
- |simplify in H11.
- apply False_ind.
- apply not_eq_true_false.
- apply sym_eq.assumption
- ]
- |apply le_S_S_to_le.
- apply H6
- [assumption
- |generalize in match H9.
- elim (p2 j)
- [reflexivity|assumption]
- ]
- ]
- ]
- ]
- |apply H3[apply le_n|assumption]
- |apply H1[apply le_n|assumption]
- ]
- |assumption
- ]
- |rewrite > false_to_sigma_p_Sn
- [apply H
- [intros.apply H1[apply le_S.assumption|assumption]
- |intros.apply H2[apply le_S.assumption|assumption]
- |intros.apply H3[apply le_S.assumption|assumption]
- |intros.apply H4[assumption|assumption]
- |intros.apply H5[assumption|assumption]
- |intros.
- elim (le_to_or_lt_eq (h1 j) n1)
- [assumption
- |absurd (j = (h n1))
- [rewrite < H10.
- rewrite > H5
- [reflexivity|assumption|assumption]
- |unfold Not.intro.
- apply not_eq_true_false.
- rewrite < H7.
- rewrite < H10.
- rewrite > H4
- [reflexivity|assumption|assumption]
- ]
- |apply le_S_S_to_le.
- apply H6[assumption|assumption]
- ]
- ]
- |assumption
- ]
- ]
- ]
-qed.
-
-(* sigma_p and Ztimes *)
-lemma Ztimes_sigma_pl: \forall z:Z.\forall n:nat.\forall p. \forall f.
-z * (sigma_p n p f) = sigma_p n p (\lambda i.z*(f i)).
+sigma_p n p1 (\lambda x.g(h x)) = sigma_p n1 p2 g.
intros.
-elim n
- [rewrite > Ztimes_z_OZ.reflexivity
- |apply (bool_elim ? (p n1)); intro
- [rewrite > true_to_sigma_p_Sn
- [rewrite > true_to_sigma_p_Sn
- [rewrite < H.
- apply distr_Ztimes_Zplus
- |assumption
- ]
- |assumption
- ]
- |rewrite > false_to_sigma_p_Sn
- [rewrite > false_to_sigma_p_Sn
- [assumption
- |assumption
- ]
- |assumption
- ]
- ]
- ]
+unfold sigma_p.
+apply (eq_iter_p_gen_gh Z OZ Zplus ? ? ? g h h1 n n1 p1 p2)
+[ apply symmetricZPlus
+| apply associative_Zplus
+| intros.
+ apply Zplus_z_OZ
+| assumption
+| assumption
+| assumption
+| assumption
+| assumption
+| assumption
+]
qed.
-lemma Ztimes_sigma_pr: \forall z:Z.\forall n:nat.\forall p. \forall f.
-(sigma_p n p f) * z = sigma_p n p (\lambda i.(f i)*z).
-intros.
-rewrite < sym_Ztimes.
-rewrite > Ztimes_sigma_pl.
-apply eq_sigma_p
- [intros.reflexivity
- |intros.apply sym_Ztimes
- ]
-qed.
theorem divides_exp_to_lt_ord:\forall n,m,j,p. O < n \to prime p \to
p \ndivides n \to j \divides n*(exp p m) \to ord j p < S m.
]
qed.
+
theorem sigma_p_divides_b:
\forall n,m,p:nat.O < n \to prime p \to Not (divides p n) \to
\forall g: nat \to Z.
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.
-cut (O < p)
- [rewrite < sigma_p2.
- apply (trans_eq ? ?
- (sigma_p (S n*S m) (\lambda x:nat.divides_b (x/S m) n)
- (\lambda x:nat.g (x/S m*(p)\sup(x\mod S m)))))
- [apply sym_eq.
- apply (eq_sigma_p_gh g ? (p_ord_inv p (S m)))
- [intros.
- lapply (divides_b_true_to_lt_O ? ? H H4).
- apply divides_to_divides_b_true
- [rewrite > (times_n_O O).
- apply lt_times
- [assumption
- |apply lt_O_exp.assumption
+unfold sigma_p.
+apply (iter_p_gen_divides Z OZ Zplus n m p ? ? ? g)
+[ assumption
+| assumption
+| assumption
+| apply symmetricZPlus
+| apply associative_Zplus
+| intros.
+ apply Zplus_z_OZ
+]
+qed.
+
+
+(* sigma_p and Ztimes *)
+lemma Ztimes_sigma_pl: \forall z:Z.\forall n:nat.\forall p. \forall f.
+z * (sigma_p n p f) = sigma_p n p (\lambda i.z*(f i)).
+intros.
+apply (distributive_times_plus_iter_p_gen Z Zplus OZ Ztimes n z p f)
+[ apply symmetricZPlus
+| apply associative_Zplus
+| intros.
+ apply Zplus_z_OZ
+| apply symmetric_Ztimes
+| apply distributive_Ztimes_Zplus
+| intros.
+ rewrite > (Ztimes_z_OZ a).
+ reflexivity
+]
+qed.
+
+lemma Ztimes_sigma_pr: \forall z:Z.\forall n:nat.\forall p. \forall f.
+(sigma_p n p f) * z = sigma_p n p (\lambda i.(f i)*z).
+intros.
+rewrite < sym_Ztimes.
+rewrite > Ztimes_sigma_pl.
+apply eq_sigma_p
+ [intros.reflexivity
+ |intros.apply sym_Ztimes
+ ]
+qed.
+
+
+theorem sigma_p_knm:
+\forall g: nat \to Z.
+\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 symmetricZPlus
+ |apply associative_Zplus
+ | intro.
+ apply (Zplus_z_OZ a)
+ | exact h11
+ | exact h12
+ | assumption
+ | assumption
+ ]
+qed.
+
+
+theorem sigma_p2_eq:
+\forall g: nat \to nat \to Z.
+\forall h11,h12,h21,h22: nat \to nat \to nat.
+\forall n1,m1,n2,m2.
+\forall p11,p21:nat \to bool.
+\forall p12,p22:nat \to nat \to bool.
+(\forall i,j. i < n2 \to j < m2 \to p21 i = true \to p22 i j = true \to
+p11 (h11 i j) = true \land p12 (h11 i j) (h12 i j) = true
+\land h21 (h11 i j) (h12 i j) = i \land h22 (h11 i j) (h12 i j) = j
+\land h11 i j < n1 \land h12 i j < m1) \to
+(\forall i,j. i < n1 \to j < m1 \to p11 i = true \to p12 i j = true \to
+p21 (h21 i j) = true \land p22 (h21 i j) (h22 i j) = true
+\land h11 (h21 i j) (h22 i j) = i \land h12 (h21 i j) (h22 i j) = j
+\land (h21 i j) < n2 \land (h22 i j) < m2) \to
+sigma_p n1 p11 (\lambda x:nat .sigma_p m1 (p12 x) (\lambda y. g x y)) =
+sigma_p n2 p21 (\lambda x:nat .sigma_p m2 (p22 x) (\lambda y. g (h11 x y) (h12 x y))).
+intros.
+unfold sigma_p.
+unfold sigma_p in \vdash (? ? (? ? ? ? (\lambda x:?.%) ? ?) ?).
+unfold sigma_p in \vdash (? ? ? (? ? ? ? (\lambda x:?.%) ? ?)).
+
+apply(iter_p_gen_2_eq Z OZ Zplus ? ? ? g h11 h12 h21 h22 n1 m1 n2 m2 p11 p21 p12 p22)
+[ apply symmetricZPlus
+| apply associative_Zplus
+| intro.
+ apply (Zplus_z_OZ a)
+| assumption
+| assumption
+]
+qed.
+
+
+
+
+(*
+
+
+
+
+
+rewrite < sigma_p2'.
+letin ha:= (\lambda x,y.(((h11 x y)*m1) + (h12 x y))).
+letin ha12:= (\lambda x.(h21 (x/m1) (x \mod m1))).
+letin ha22:= (\lambda x.(h22 (x/m1) (x \mod m1))).
+
+apply (trans_eq ? ?
+(sigma_p n2 p21 (\lambda x:nat. sigma_p m2 (p22 x)
+ (\lambda y:nat.(g (((h11 x y)*m1+(h12 x y))/m1) (((h11 x y)*m1+(h12 x y))\mod m1)) ) ) ))
+[
+ apply (sigma_p_knm (\lambda e. (g (e/m1) (e \mod m1))) ha ha12 ha22);intros
+ [ elim (and_true ? ? H3).
+ cut(O \lt m1)
+ [ cut(x/m1 < n1)
+ [ cut((x \mod m1) < m1)
+ [ elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ split
+ [ split
+ [ split
+ [ split
+ [ assumption
+ | assumption
+ ]
+ | rewrite > H11.
+ rewrite > H10.
+ apply sym_eq.
+ apply div_mod.
+ assumption
+ ]
+ | assumption
+ ]
+ | assumption
]
- |apply divides_times
- [apply divides_b_true_to_divides.assumption
- |apply (witness ? ? (p \sup (m-i \mod (S m)))).
- rewrite < exp_plus_times.
- apply eq_f.
- rewrite > sym_plus.
- apply plus_minus_m_m.
- autobatch
+ | apply lt_mod_m_m.
+ assumption
+ ]
+ | apply (lt_times_n_to_lt m1)
+ [ assumption
+ | apply (le_to_lt_to_lt ? x)
+ [ apply (eq_plus_to_le ? ? (x \mod m1)).
+ apply div_mod.
+ assumption
+ | assumption
+ ]
+ ]
+ ]
+ | apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H6).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n.
+ ]
+ | elim (H ? ? H2 H3 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ cut(((h11 i j)*m1 + (h12 i j))/m1 = (h11 i j))
+ [ cut(((h11 i j)*m1 + (h12 i j)) \mod m1 = (h12 i j))
+ [ split
+ [ split
+ [ split
+ [ apply true_to_true_to_andb_true
+ [ rewrite > Hcut.
+ assumption
+ | rewrite > Hcut1.
+ rewrite > Hcut.
+ assumption
+ ]
+ | rewrite > Hcut1.
+ rewrite > Hcut.
+ assumption
+ ]
+ | rewrite > Hcut1.
+ rewrite > Hcut.
+ assumption
]
+ | cut(O \lt m1)
+ [ cut(O \lt n1)
+ [ apply (lt_to_le_to_lt ? ((h11 i j)*m1 + m1) )
+ [ apply (lt_plus_r).
+ assumption
+ | rewrite > sym_plus.
+ rewrite > (sym_times (h11 i j) m1).
+ rewrite > times_n_Sm.
+ rewrite > sym_times.
+ apply (le_times_l).
+ assumption
+ ]
+ | apply not_le_to_lt.unfold.intro.
+ generalize in match H9.
+ apply (le_n_O_elim ? H8).
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ | apply not_le_to_lt.unfold.intro.
+ generalize in match H7.
+ apply (le_n_O_elim ? H8).
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
]
- |intros.
- lapply (divides_b_true_to_lt_O ? ? H H4).
- unfold p_ord_inv.
- rewrite > (p_ord_exp1 p ? (i \mod (S m)) (i/S m))
- [change with ((i/S m)*S m+i \mod S m=i).
- apply sym_eq.
- apply div_mod.
- apply lt_O_S
- |assumption
- |unfold Not.intro.
- apply H2.
- apply (trans_divides ? (i/ S m))
- [assumption|
- apply divides_b_true_to_divides;assumption]
- |apply sym_times.
+ | rewrite > (mod_plus_times m1 (h11 i j) (h12 i j)).
+ reflexivity.
+ assumption
+ ]
+ | rewrite > (div_plus_times m1 (h11 i j) (h12 i j)).
+ reflexivity.
+ assumption
+ ]
+ ]
+| apply (eq_sigma_p1)
+ [ intros. reflexivity
+ | intros.
+ apply (eq_sigma_p1)
+ [ intros. reflexivity
+ | intros.
+ rewrite > (div_plus_times)
+ [ rewrite > (mod_plus_times)
+ [ reflexivity
+ | elim (H x x1 H2 H4 H3 H5).
+ assumption
]
- |intros.
- apply le_S_S.
- apply le_times
- [apply le_S_S_to_le.
- change with ((i/S m) < S n).
- apply (lt_times_to_lt_l m).
- apply (le_to_lt_to_lt ? i)
- [autobatch|assumption]
- |apply le_exp
+ | elim (H x x1 H2 H4 H3 H5).
+ assumption
+ ]
+ ]
+ ]
+]
+qed.
+
+rewrite < sigma_p2' in \vdash (? ? ? %).
+apply sym_eq.
+letin h := (\lambda x.(h11 (x/m2) (x\mod m2))*m1 + (h12 (x/m2) (x\mod m2))).
+letin h1 := (\lambda x.(h21 (x/m1) (x\mod m1))*m2 + (h22 (x/m1) (x\mod m1))).
+apply (trans_eq ? ?
+ (sigma_p (n2*m2) (\lambda x:nat.p21 (x/m2)\land p22 (x/m2) (x\mod m2))
+ (\lambda x:nat.g ((h x)/m1) ((h x)\mod m1))))
+ [clear h.clear h1.
+ apply eq_sigma_p1
+ [intros.reflexivity
+ |intros.
+ cut (O < m2)
+ [cut (x/m2 < n2)
+ [cut (x \mod m2 < m2)
+ [elim (and_true ? ? H3).
+ elim (H ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ apply eq_f2
+ [apply sym_eq.
+ apply div_plus_times.
+ assumption
+ |
+ apply sym_eq.
+ apply mod_plus_times.
+ assumption
+ ]
+ |apply lt_mod_m_m.
+ assumption
+ ]
+ |apply (lt_times_n_to_lt m2)
[assumption
- |apply le_S_S_to_le.
- apply lt_mod_m_m.
- apply lt_O_S
+ |apply (le_to_lt_to_lt ? x)
+ [apply (eq_plus_to_le ? ? (x \mod m2)).
+ apply div_mod.
+ assumption
+ |assumption
+ ]
]
]
- |intros.
- cut (ord j p < S m)
- [rewrite > div_p_ord_inv
- [apply divides_to_divides_b_true
- [apply lt_O_ord_rem
- [elim H1.assumption
- |apply (divides_b_true_to_lt_O ? ? ? H4).
- rewrite > (times_n_O O).
- apply lt_times
- [assumption|apply lt_O_exp.assumption]
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ ]
+ |apply (eq_sigma_p_gh ? h h1);intros
+ [cut (O < m2)
+ [cut (i/m2 < n2)
+ [cut (i \mod m2 < m2)
+ [elim (and_true ? ? H3).
+ elim (H ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))/m1 =
+ h11 (i/m2) (i\mod m2))
+ [cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))\mod m1 =
+ h12 (i/m2) (i\mod m2))
+ [rewrite > Hcut3.
+ rewrite > Hcut4.
+ rewrite > H6.
+ rewrite > H12.
+ reflexivity
+ |apply mod_plus_times.
+ assumption
]
- |apply (divides_exp_to_divides_ord_rem ? m ? ? H H1 H2).
- apply divides_b_true_to_divides.
+ |apply div_plus_times.
assumption
]
+ |apply lt_mod_m_m.
+ assumption
+ ]
+ |apply (lt_times_n_to_lt m2)
+ [assumption
+ |apply (le_to_lt_to_lt ? i)
+ [apply (eq_plus_to_le ? ? (i \mod m2)).
+ apply div_mod.
+ assumption
|assumption
+ ]
]
- |apply (divides_exp_to_lt_ord ? ? ? ? H H1 H2).
- apply (divides_b_true_to_divides ? ? H4).
- apply (divides_b_true_to_lt_O ? ? H4)
]
- |intros.
- cut (ord j p < S m)
- [rewrite > div_p_ord_inv
- [rewrite > mod_p_ord_inv
- [rewrite > sym_times.
- apply sym_eq.
- apply exp_ord
- [elim H1.assumption
- |apply (divides_b_true_to_lt_O ? ? ? H4).
- rewrite > (times_n_O O).
- apply lt_times
- [assumption|apply lt_O_exp.assumption]
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ |cut (O < m2)
+ [cut (i/m2 < n2)
+ [cut (i \mod m2 < m2)
+ [elim (and_true ? ? H3).
+ elim (H ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))/m1 =
+ h11 (i/m2) (i\mod m2))
+ [cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))\mod m1 =
+ h12 (i/m2) (i\mod m2))
+ [rewrite > Hcut3.
+ rewrite > Hcut4.
+ rewrite > H10.
+ rewrite > H11.
+ apply sym_eq.
+ apply div_mod.
+ assumption
+ |apply mod_plus_times.
+ assumption
]
- |apply (divides_exp_to_lt_ord ? ? ? ? H H1 H2).
- apply (divides_b_true_to_divides ? ? H4).
- apply (divides_b_true_to_lt_O ? ? H4)
+ |apply div_plus_times.
+ assumption
+ ]
+ |apply lt_mod_m_m.
+ assumption
+ ]
+ |apply (lt_times_n_to_lt m2)
+ [assumption
+ |apply (le_to_lt_to_lt ? i)
+ [apply (eq_plus_to_le ? ? (i \mod m2)).
+ apply div_mod.
+ assumption
+ |assumption
]
- |assumption
]
- |apply (divides_exp_to_lt_ord ? ? ? ? H H1 H2).
- apply (divides_b_true_to_divides ? ? H4).
- apply (divides_b_true_to_lt_O ? ? H4).
]
- |intros.
- rewrite > eq_p_ord_inv.
- rewrite > sym_plus.
- apply (lt_to_le_to_lt ? (S m +ord_rem j p*S m))
- [apply lt_plus_l.
- apply le_S_S.
- cut (m = ord (n*(p \sup m)) p)
- [rewrite > Hcut1.
- apply divides_to_le_ord
- [apply (divides_b_true_to_lt_O ? ? ? H4).
- rewrite > (times_n_O O).
- apply lt_times
- [assumption|apply lt_O_exp.assumption]
- |rewrite > (times_n_O O).
- apply lt_times
- [assumption|apply lt_O_exp.assumption]
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ |cut (O < m2)
+ [cut (i/m2 < n2)
+ [cut (i \mod m2 < m2)
+ [elim (and_true ? ? H3).
+ elim (H ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ apply lt_times_plus_times
+ [assumption|assumption]
+ |apply lt_mod_m_m.
+ assumption
+ ]
+ |apply (lt_times_n_to_lt m2)
+ [assumption
+ |apply (le_to_lt_to_lt ? i)
+ [apply (eq_plus_to_le ? ? (i \mod m2)).
+ apply div_mod.
+ assumption
|assumption
- |apply divides_b_true_to_divides.
+ ]
+ ]
+ ]
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ |cut (O < m1)
+ [cut (j/m1 < n1)
+ [cut (j \mod m1 < m1)
+ [elim (and_true ? ? H3).
+ elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))/m2 =
+ h21 (j/m1) (j\mod m1))
+ [cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))\mod m2 =
+ h22 (j/m1) (j\mod m1))
+ [rewrite > Hcut3.
+ rewrite > Hcut4.
+ rewrite > H6.
+ rewrite > H12.
+ reflexivity
+ |apply mod_plus_times.
+ assumption
+ ]
+ |apply div_plus_times.
assumption
]
- |unfold ord.
- rewrite > sym_times.
- rewrite > (p_ord_exp1 p ? m n)
- [reflexivity
- |assumption
+ |apply lt_mod_m_m.
+ assumption
+ ]
+ |apply (lt_times_n_to_lt m1)
+ [assumption
+ |apply (le_to_lt_to_lt ? j)
+ [apply (eq_plus_to_le ? ? (j \mod m1)).
+ apply div_mod.
+ assumption
|assumption
- |reflexivity
]
]
- |change with (S (ord_rem j p)*S m \le S n*S m).
- apply le_times_l.
- apply le_S_S.
- apply divides_to_le
+ ]
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ |cut (O < m1)
+ [cut (j/m1 < n1)
+ [cut (j \mod m1 < m1)
+ [elim (and_true ? ? H3).
+ elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))/m2 =
+ h21 (j/m1) (j\mod m1))
+ [cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))\mod m2 =
+ h22 (j/m1) (j\mod m1))
+ [rewrite > Hcut3.
+ rewrite > Hcut4.
+ rewrite > H10.
+ rewrite > H11.
+ apply sym_eq.
+ apply div_mod.
+ assumption
+ |apply mod_plus_times.
+ assumption
+ ]
+ |apply div_plus_times.
+ assumption
+ ]
+ |apply lt_mod_m_m.
+ assumption
+ ]
+ |apply (lt_times_n_to_lt m1)
[assumption
- |apply (divides_exp_to_divides_ord_rem ? m ? ? H H1 H2).
- apply divides_b_true_to_divides.
+ |apply (le_to_lt_to_lt ? j)
+ [apply (eq_plus_to_le ? ? (j \mod m1)).
+ apply div_mod.
+ assumption
+ |assumption
+ ]
+ ]
+ ]
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
+ ]
+ |cut (O < m1)
+ [cut (j/m1 < n1)
+ [cut (j \mod m1 < m1)
+ [elim (and_true ? ? H3).
+ elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+ elim H6.clear H6.
+ elim H8.clear H8.
+ elim H6.clear H6.
+ elim H8.clear H8.
+ apply (lt_times_plus_times ? ? ? m2)
+ [assumption|assumption]
+ |apply lt_mod_m_m.
assumption
+ ]
+ |apply (lt_times_n_to_lt m1)
+ [assumption
+ |apply (le_to_lt_to_lt ? j)
+ [apply (eq_plus_to_le ? ? (j \mod m1)).
+ apply div_mod.
+ assumption
+ |assumption
+ ]
]
]
- ]
- |apply eq_sigma_p
- [intros.
- elim (divides_b (x/S m) n);reflexivity
- |intros.reflexivity
+ |apply not_le_to_lt.unfold.intro.
+ generalize in match H2.
+ apply (le_n_O_elim ? H4).
+ rewrite < times_n_O.
+ apply le_to_not_lt.
+ apply le_O_n
]
]
- |elim H1.apply lt_to_le.assumption
]
qed.
-
+*)
+
+