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_exp_times : \forall n,p,q:nat.
44 (n \sup p) \sup q = n \sup (p * q).
46 elim q.simplify.rewrite < times_n_O.simplify.reflexivity.
47 simplify.rewrite > H.rewrite < exp_plus_times.
48 rewrite < times_n_Sm.reflexivity.
51 theorem lt_O_exp: \forall n,m:nat. O < n \to O < n \sup m.
52 intros.elim m.simplify.unfold lt.apply le_n.
53 simplify.unfold lt.rewrite > times_n_SO.
54 apply le_times.assumption.assumption.
57 theorem lt_m_exp_nm: \forall n,m:nat. (S O) < n \to m < n \sup m.
58 intros.elim m.simplify.unfold lt.apply le_n.
60 apply (trans_le ? ((S(S O))*(S n1))).
62 rewrite < plus_n_Sm.apply le_S_S.apply le_S_S.
65 apply le_times.assumption.assumption.
68 theorem exp_to_eq_O: \forall n,m:nat. (S O) < n
69 \to n \sup m = (S O) \to m = O.
70 intros.apply antisym_le.apply le_S_S_to_le.
71 rewrite < H1.change with (m < n \sup m).
72 apply lt_m_exp_nm.assumption.
76 theorem injective_exp_r: \forall n:nat. (S O) < n \to
77 injective nat nat (\lambda m:nat. n \sup m).
79 apply (nat_elim2 (\lambda x,y.n \sup x = n \sup y \to x = y)).
80 intros.apply sym_eq.apply (exp_to_eq_O n).assumption.
81 rewrite < H1.reflexivity.
82 intros.apply (exp_to_eq_O n).assumption.assumption.
85 (* esprimere inj_times senza S *)
86 cut (\forall a,b:nat.O < n \to n*a=n*b \to a=b).
87 apply Hcut.simplify.unfold lt.apply le_S_S_to_le. apply le_S. assumption.
91 intros.apply False_ind.apply (not_le_Sn_O O H3).
93 apply (inj_times_r m1).assumption.
96 variant inj_exp_r: \forall p:nat. (S O) < p \to \forall n,m:nat.
97 p \sup n = p \sup m \to n = m \def
100 theorem le_exp: \forall n,m,p:nat. O < p \to n \le m \to exp p n \le exp p m.
103 apply lt_O_exp.assumption
106 apply (le_to_not_lt ? ? ? H1).
112 |apply H[assumption|apply le_S_S_to_le.assumption]
117 theorem lt_exp: \forall n,m,p:nat. S O < p \to n < m \to exp p n < exp p m.
120 apply (lt_O_n_elim ? H1).intro.
122 rewrite > times_n_SO.
126 apply (trans_lt ? (S O))[apply le_n|assumption]
130 apply (le_to_not_lt ? ? ? H1).
134 [apply (trans_lt ? (S O))[apply le_n|assumption]
137 |apply le_S_S_to_le.assumption
143 theorem le_exp_to_le:
144 \forall a,n,m. S O < a \to exp a n \le exp a m \to n \le m.
146 apply nat_elim2;intros
149 apply (le_to_not_lt ? ? H1).
151 rewrite > times_n_SO.
152 apply lt_to_le_to_lt_times
154 |apply lt_O_exp.apply lt_to_le.assumption
155 |apply lt_O_exp.apply lt_to_le.assumption
161 |apply (le_times_to_le a)
162 [apply lt_to_le.assumption|assumption]