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 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 include "nat/div_and_mod.ma".
16 include "nat/lt_arith.ma".
18 let rec exp n m on m\def
21 | (S p) \Rightarrow (times n (exp n p)) ].
23 interpretation "natural exponent" 'exp a b = (cic:/matita/nat/exp/exp.con a b).
25 theorem exp_plus_times : \forall n,p,q:nat.
26 n \sup (p + q) = (n \sup p) * (n \sup q).
28 simplify.rewrite < plus_n_O.reflexivity.
29 simplify.rewrite > H.symmetry.
33 theorem exp_n_O : \forall n:nat. S O = n \sup O.
34 intro.simplify.reflexivity.
37 theorem exp_n_SO : \forall n:nat. n = n \sup (S O).
38 intro.simplify.rewrite < times_n_SO.reflexivity.
41 theorem exp_SO_n : \forall n:nat. S O = (S O) \sup n.
44 |simplify.rewrite < plus_n_O.assumption
48 theorem exp_SSO: \forall n. exp n (S(S O)) = n*n.
54 theorem exp_exp_times : \forall n,p,q:nat.
55 (n \sup p) \sup q = n \sup (p * q).
57 elim q.simplify.rewrite < times_n_O.simplify.reflexivity.
58 simplify.rewrite > H.rewrite < exp_plus_times.
59 rewrite < times_n_Sm.reflexivity.
62 theorem lt_O_exp: \forall n,m:nat. O < n \to O < n \sup m.
63 intros.elim m.simplify.unfold lt.apply le_n.
64 simplify.unfold lt.rewrite > times_n_SO.
65 apply le_times.assumption.assumption.
68 theorem lt_m_exp_nm: \forall n,m:nat. (S O) < n \to m < n \sup m.
69 intros.elim m.simplify.unfold lt.apply le_n.
71 apply (trans_le ? ((S(S O))*(S n1))).
73 rewrite < plus_n_Sm.apply le_S_S.apply le_S_S.
76 apply le_times.assumption.assumption.
79 theorem exp_to_eq_O: \forall n,m:nat. (S O) < n
80 \to n \sup m = (S O) \to m = O.
81 intros.apply antisym_le.apply le_S_S_to_le.
82 rewrite < H1.change with (m < n \sup m).
83 apply lt_m_exp_nm.assumption.
87 theorem injective_exp_r: \forall n:nat. (S O) < n \to
88 injective nat nat (\lambda m:nat. n \sup m).
90 apply (nat_elim2 (\lambda x,y.n \sup x = n \sup y \to x = y)).
91 intros.apply sym_eq.apply (exp_to_eq_O n).assumption.
92 rewrite < H1.reflexivity.
93 intros.apply (exp_to_eq_O n).assumption.assumption.
96 (* esprimere inj_times senza S *)
97 cut (\forall a,b:nat.O < n \to n*a=n*b \to a=b).
98 apply Hcut.simplify.unfold lt.apply le_S_S_to_le. apply le_S. assumption.
102 intros.apply False_ind.apply (not_le_Sn_O O H3).
104 apply (inj_times_r m1).assumption.
107 variant inj_exp_r: \forall p:nat. (S O) < p \to \forall n,m:nat.
108 p \sup n = p \sup m \to n = m \def
111 theorem le_exp: \forall n,m,p:nat. O < p \to n \le m \to exp p n \le exp p m.
114 apply lt_O_exp.assumption
117 apply (le_to_not_lt ? ? ? H1).
123 |apply H[assumption|apply le_S_S_to_le.assumption]
128 theorem lt_exp: \forall n,m,p:nat. S O < p \to n < m \to exp p n < exp p m.
131 apply (lt_O_n_elim ? H1).intro.
133 rewrite > times_n_SO.
137 apply (trans_lt ? (S O))[apply le_n|assumption]
141 apply (le_to_not_lt ? ? ? H1).
145 [apply (trans_lt ? (S O))[apply le_n|assumption]
148 |apply le_S_S_to_le.assumption
154 theorem lt_exp1: \forall n,m,p:nat. O < p \to n < m \to exp n p < exp m p.
157 [rewrite < exp_n_SO.rewrite < exp_n_SO.assumption
159 apply lt_times;assumption
163 theorem le_exp_to_le:
164 \forall a,n,m. S O < a \to exp a n \le exp a m \to n \le m.
166 apply nat_elim2;intros
169 apply (le_to_not_lt ? ? H1).
171 rewrite > times_n_SO.
172 apply lt_to_le_to_lt_times
174 |apply lt_O_exp.apply lt_to_le.assumption
175 |apply lt_O_exp.apply lt_to_le.assumption
181 |apply (le_times_to_le a)
182 [apply lt_to_le.assumption|assumption]
187 theorem le_exp_to_le1 : \forall n,m,p.O < p \to exp n p \leq exp m p \to n \leq m.
188 intros;apply not_lt_to_le;intro;apply (lt_to_not_le ? ? ? H1);
189 apply lt_exp1;assumption.
192 theorem lt_exp_to_lt:
193 \forall a,n,m. S O < a \to exp a n < exp a m \to n < m.
195 elim (le_to_or_lt_eq n m)
198 apply (lt_to_not_eq ? ? H1).
201 |apply (le_exp_to_le a)
209 theorem lt_exp_to_lt1:
210 \forall a,n,m. O < a \to exp n a < exp m a \to n < m.
212 elim (le_to_or_lt_eq n m)
215 apply (lt_to_not_eq ? ? H1).
218 |apply (le_exp_to_le1 ? ? a)
227 \forall n,m,p. exp n p * exp m p = exp (n*m) p.
229 [simplify.reflexivity
231 rewrite > assoc_times.
232 rewrite < assoc_times in ⊢ (? ? (? ? %) ?).
233 rewrite < sym_times in ⊢ (? ? (? ? (? % ?)) ?).
234 rewrite > assoc_times in ⊢ (? ? (? ? %) ?).
235 rewrite < assoc_times.
241 theorem monotonic_exp1: \forall n.
242 monotonic nat le (\lambda x.(exp x n)).
243 unfold monotonic. intros.
247 apply le_times;assumption