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 set "baseuri" "cic:/matita/nat/exp".
17 include "nat/div_and_mod.ma".
18 include "nat/lt_arith.ma".
20 let rec exp n m on m\def
23 | (S p) \Rightarrow (times n (exp n p)) ].
25 interpretation "natural exponent" 'exp a b = (cic:/matita/nat/exp/exp.con a b).
27 theorem exp_plus_times : \forall n,p,q:nat.
28 n \sup (p + q) = (n \sup p) * (n \sup q).
30 simplify.rewrite < plus_n_O.reflexivity.
31 simplify.rewrite > H.symmetry.
35 theorem exp_n_O : \forall n:nat. S O = n \sup O.
36 intro.simplify.reflexivity.
39 theorem exp_n_SO : \forall n:nat. n = n \sup (S O).
40 intro.simplify.rewrite < times_n_SO.reflexivity.
43 theorem exp_SSO: \forall n. exp n (S(S O)) = n*n.
49 theorem exp_exp_times : \forall n,p,q:nat.
50 (n \sup p) \sup q = n \sup (p * q).
52 elim q.simplify.rewrite < times_n_O.simplify.reflexivity.
53 simplify.rewrite > H.rewrite < exp_plus_times.
54 rewrite < times_n_Sm.reflexivity.
57 theorem lt_O_exp: \forall n,m:nat. O < n \to O < n \sup m.
58 intros.elim m.simplify.unfold lt.apply le_n.
59 simplify.unfold lt.rewrite > times_n_SO.
60 apply le_times.assumption.assumption.
63 theorem lt_m_exp_nm: \forall n,m:nat. (S O) < n \to m < n \sup m.
64 intros.elim m.simplify.unfold lt.apply le_n.
66 apply (trans_le ? ((S(S O))*(S n1))).
68 rewrite < plus_n_Sm.apply le_S_S.apply le_S_S.
71 apply le_times.assumption.assumption.
74 theorem exp_to_eq_O: \forall n,m:nat. (S O) < n
75 \to n \sup m = (S O) \to m = O.
76 intros.apply antisym_le.apply le_S_S_to_le.
77 rewrite < H1.change with (m < n \sup m).
78 apply lt_m_exp_nm.assumption.
82 theorem injective_exp_r: \forall n:nat. (S O) < n \to
83 injective nat nat (\lambda m:nat. n \sup m).
85 apply (nat_elim2 (\lambda x,y.n \sup x = n \sup y \to x = y)).
86 intros.apply sym_eq.apply (exp_to_eq_O n).assumption.
87 rewrite < H1.reflexivity.
88 intros.apply (exp_to_eq_O n).assumption.assumption.
91 (* esprimere inj_times senza S *)
92 cut (\forall a,b:nat.O < n \to n*a=n*b \to a=b).
93 apply Hcut.simplify.unfold lt.apply le_S_S_to_le. apply le_S. assumption.
97 intros.apply False_ind.apply (not_le_Sn_O O H3).
99 apply (inj_times_r m1).assumption.
102 variant inj_exp_r: \forall p:nat. (S O) < p \to \forall n,m:nat.
103 p \sup n = p \sup m \to n = m \def
106 theorem le_exp: \forall n,m,p:nat. O < p \to n \le m \to exp p n \le exp p m.
109 apply lt_O_exp.assumption
112 apply (le_to_not_lt ? ? ? H1).
118 |apply H[assumption|apply le_S_S_to_le.assumption]
123 theorem lt_exp: \forall n,m,p:nat. S O < p \to n < m \to exp p n < exp p m.
126 apply (lt_O_n_elim ? H1).intro.
128 rewrite > times_n_SO.
132 apply (trans_lt ? (S O))[apply le_n|assumption]
136 apply (le_to_not_lt ? ? ? H1).
140 [apply (trans_lt ? (S O))[apply le_n|assumption]
143 |apply le_S_S_to_le.assumption
149 theorem le_exp_to_le:
150 \forall a,n,m. S O < a \to exp a n \le exp a m \to n \le m.
152 apply nat_elim2;intros
155 apply (le_to_not_lt ? ? H1).
157 rewrite > times_n_SO.
158 apply lt_to_le_to_lt_times
160 |apply lt_O_exp.apply lt_to_le.assumption
161 |apply lt_O_exp.apply lt_to_le.assumption
167 |apply (le_times_to_le a)
168 [apply lt_to_le.assumption|assumption]
173 theorem lt_exp_to_lt:
174 \forall a,n,m. S O < a \to exp a n < exp a m \to n < m.
176 elim (le_to_or_lt_eq n m)
179 apply (lt_to_not_eq ? ? H1).
182 |apply (le_exp_to_le a)
191 \forall n,m,p. exp n p * exp m p = exp (n*m) p.
193 [simplify.reflexivity
195 rewrite > assoc_times.
196 rewrite < assoc_times in ⊢ (? ? (? ? %) ?).
197 rewrite < sym_times in ⊢ (? ? (? ? (? % ?)) ?).
198 rewrite > assoc_times in ⊢ (? ? (? ? %) ?).
199 rewrite < assoc_times.
205 theorem monotonic_exp1: \forall n.
206 monotonic nat le (\lambda x.(exp x n)).
207 unfold monotonic. intros.
211 apply le_times;assumption