2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department of the University of Bologna, Italy.
7 ||A|| This file is distributed under the terms of the
8 \ / GNU General Public License Version 2
10 V_______________________________________________________________ *)
12 include "arithmetics/primes.ma".
13 include "arithmetics/bigops.ma".
17 notation "∑_{ ident i < n | p } f"
19 for @{'bigop $n plus 0 (λ${ident i}. $p) (λ${ident i}. $f)}.
21 notation "∑_{ ident i < n } f"
23 for @{'bigop $n plus 0 (λ${ident i}.true) (λ${ident i}. $f)}.
25 notation "∑_{ ident j ∈ [a,b[ } f"
27 for @{'bigop ($b-$a) plus 0 (λ${ident j}.((λ${ident j}.true) (${ident j}+$a)))
28 (λ${ident j}.((λ${ident j}.$f)(${ident j}+$a)))}.
30 notation "∑_{ ident j ∈ [a,b[ | p } f"
32 for @{'bigop ($b-$a) plus 0 (λ${ident j}.((λ${ident j}.$p) (${ident j}+$a)))
33 (λ${ident j}.((λ${ident j}.$f)(${ident j}+$a)))}.
35 notation "∏_{ ident i < n | p} f"
37 for @{'bigop $n times 1 (λ${ident i}.$p) (λ${ident i}. $f)}.
39 notation "∏_{ ident i < n } f"
41 for @{'bigop $n times 1 (λ${ident i}.true) (λ${ident i}. $f)}.
43 notation "∏_{ ident j ∈ [a,b[ } f"
45 for @{'bigop ($b-$a) times 1 (λ${ident j}.((λ${ident j}.true) (${ident j}+$a)))
46 (λ${ident j}.((λ${ident j}.$f)(${ident j}+$a)))}.
48 notation "∏_{ ident j ∈ [a,b[ | p } f"
50 for @{'bigop ($b-$a) times 1 (λ${ident j}.((λ${ident j}.$p) (${ident j}+$a)))
51 (λ${ident j}.((λ${ident j}.$f)(${ident j}+$a)))}.
53 (* instances of associative and commutative operations *)
55 definition plusA ≝ mk_Aop nat 0 plus (λa.refl ? a) (λn.sym_eq ??? (plus_n_O n))
56 (λa,b,c.sym_eq ??? (associative_plus a b c)).
58 definition plusAC ≝ mk_ACop nat 0 plusA commutative_plus.
60 definition timesA ≝ mk_Aop nat 1 times
61 (λa.sym_eq ??? (plus_n_O a)) (λn.sym_eq ??? (times_n_1 n))
62 (λa,b,c.sym_eq ??? (associative_times a b c)).
64 definition timesAC ≝ mk_ACop nat 1 timesA commutative_times.
66 definition natD ≝ mk_Dop nat 0 plusAC times (λn.(sym_eq ??? (times_n_O n)))
67 distributive_times_plus.
69 (********************************************************)
71 theorem sigma_const: ∀n:nat. ∑_{i<n} 1 = n.
72 #n elim n // #n1 >bigop_Strue //
75 (* monotonicity; these roperty should be expressed at a more
79 ∀n:nat. ∀p1,p2:nat → bool. ∀g1,g2:nat → nat.
80 (∀i. i < n → p1 i = true → p2 i = true ) →
81 (∀i. i < n → p1 i = true → g1 i ≤ g2 i ) →
82 ∑_{i < n | p1 i} (g1 i) ≤ ∑_{i < n | p2 i} (g2 i).
83 #n #p1 #p2 #g1 #g2 elim n
87 [#j #ltin1 #Hgj @(H2 … Hgj) @le_S //
88 |#j #ltin1 #Hp1j @(H1 … Hp1j) @le_S //
90 cases (true_or_false (p2 n1)) #Hp2
91 [>bigop_Strue in ⊢ (??%); [2:@Hp2]
92 cases (true_or_false (p1 n1)) #Hp1
93 [>bigop_Strue [2:@Hp1] @(le_plus … Hind) @H2 //
94 |>bigop_Sfalse [2:@Hp1] @le_plus_a //
97 [cases (true_or_false (p1 n1)) #Hp1
98 [>(H1 … (le_n ?) Hp1) in Hp2; #H destruct (H) | //]
100 >bigop_Sfalse [2:@Hp1] >bigop_Sfalse [2:@Hp2] //
106 ∀n:nat. ∀p1,p2:nat → bool. ∀g1,g2:nat → nat.
107 (∀i. i < n → p1 i = true → p2 i = true) →
108 (∀i. i < n → p1 i = true → g1 i ≤ g2 i ) →
109 (∃i. i < n ∧ ((p1 i = true) ∧ (g1 i < g2 i)
110 ∨ (p1 i = false ∧ (p2 i = true) ∧ (0 < g2 i)))) →
111 ∑_{i < n | p1 i} (g1 i) < ∑_{i < n | p2 i} (g2 i).
112 #n #p1 #p2 #g1 #g2 #H1 #H2 * #k * #ltk *
114 lapply (H1 k ltk p1k) #p2k
115 >(bigop_diff p1 ?? plusAC … ltk p1k)
116 >(bigop_diff p2 ?? plusAC … ltk p2k) whd
117 cut (∀a,b. S a + b = S(a +b)) [//] #Hplus <Hplus @le_plus
120 [#i #ltin #H @true_to_andb_true
121 [@(andb_true_l … H) | @(H1 i ltin) @(andb_true_r … H)]
122 |#i #ltin #H @(H2 i ltin) @(andb_true_r … H)
125 |* * #p1k #p2k #posg2
126 >(bigop_diff p2 ?? plusAC … ltk p2k) whd
127 cut (∀a. S 0 + a = S a) [//] #H0 <(H0 (bigop n ?????)) @le_plus
130 [#i #ltin #H @true_to_andb_true
131 [cases (true_or_false (eqb k i)) #Hc >Hc
132 [normalize <H <p1k >(eqb_true_to_eq … Hc) //|//]
134 |#i #ltin #H @(H2 i ltin) @H
140 ∀n.∀p:nat → bool.∀g1,g2:nat → nat.
141 (∀i.i<n → p i = true → g1 i ≤ g2 i ) →
142 ∏_{i < n | p i} (g1 i) ≤ ∏_{i < n | p i} (g2 i).
145 |#n1 #Hind #Hle cases (true_or_false (p n1)) #Hcase
146 [ >bigop_Strue // >bigop_Strue // @le_times
147 [@Hle // |@Hind #i #lti #Hpi @Hle [@lt_to_le @le_S_S @lti|@Hpi]]
148 |>bigop_Sfalse // >bigop_Sfalse // @Hind
149 #i #lti #Hpi @Hle [@lt_to_le @le_S_S @lti|@Hpi]
154 theorem exp_sigma: ∀n,a,p.
155 ∏_{i < n | p i} a = exp a (∑_{i < n | p i} 1).
156 #n #a #p elim n // #n1 cases (true_or_false (p n1)) #Hcase
157 [>bigop_Strue // >bigop_Strue // |>bigop_Sfalse // >bigop_Sfalse //]
160 theorem times_pi: ∀n,p,f,g.
161 ∏_{i<n|p i}(f i*g i) = ∏_{i<n|p i}(f i) * ∏_{i<n|p i}(g i).
162 #n #p #f #g elim n // #n1 cases (true_or_false (p n1)) #Hcase #Hind
163 [>bigop_Strue // >bigop_Strue // >bigop_Strue //
164 |>bigop_Sfalse // >bigop_Sfalse // >bigop_Sfalse //
169 ∏_{i < n | p i} 1 = 1.
170 #n #p elim n // #n1 #Hind cases (true_or_false (p n1)) #Hc
171 [>bigop_Strue >Hind // |>bigop_Sfalse // ]
174 theorem exp_pi: ∀n,m,p,f.
175 ∏_{i < n | p i}(exp (f i) m) = exp (∏_{i < n | p i}(f i)) m.
178 |#m1 #Hind >times_pi >Hind %
182 theorem exp_sigma_l: ∀n,a,p,f.
183 ∏_{i < n | p i} (exp a (f i)) = exp a (∑_{i < n | p i}(f i)).
184 #n #a #p #f elim n // #i #Hind cases (true_or_false (p i)) #Hc
185 [>bigop_Strue [>bigop_Strue [>Hind >exp_plus_times // |//] |//]
186 |>bigop_Sfalse [>bigop_Sfalse [@Hind|//] | //]