]> matita.cs.unibo.it Git - helm.git/blob - matita/library/nat/exp.ma
Towards chebyshev.
[helm.git] / matita / library / nat / exp.ma
1 (**************************************************************************)
2 (*       ___                                                                *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||       A.Asperti, C.Sacerdoti Coen,                          *)
8 (*      ||A||       E.Tassi, S.Zacchiroli                                 *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU Lesser General Public License Version 2.1         *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 set "baseuri" "cic:/matita/nat/exp".
16
17 include "nat/div_and_mod.ma".
18 include "nat/lt_arith.ma".
19
20 let rec exp n m on m\def 
21  match m with 
22  [ O \Rightarrow (S O)
23  | (S p) \Rightarrow (times n (exp n p)) ].
24
25 interpretation "natural exponent" 'exp a b = (cic:/matita/nat/exp/exp.con a b).
26
27 theorem exp_plus_times : \forall n,p,q:nat. 
28 n \sup (p + q) = (n \sup p) * (n \sup q).
29 intros.elim p.
30 simplify.rewrite < plus_n_O.reflexivity.
31 simplify.rewrite > H.symmetry.
32 apply assoc_times.
33 qed.
34
35 theorem exp_n_O : \forall n:nat. S O = n \sup O.
36 intro.simplify.reflexivity.
37 qed.
38
39 theorem exp_n_SO : \forall n:nat. n = n \sup (S O).
40 intro.simplify.rewrite < times_n_SO.reflexivity.
41 qed.
42
43 theorem exp_SSO: \forall n. exp n (S(S O)) = n*n.
44 intro.simplify.
45 rewrite < times_n_SO.
46 reflexivity.
47 qed.
48
49 theorem exp_exp_times : \forall n,p,q:nat. 
50 (n \sup p) \sup q = n \sup (p * q).
51 intros.
52 elim q.simplify.rewrite < times_n_O.simplify.reflexivity.
53 simplify.rewrite > H.rewrite < exp_plus_times.
54 rewrite < times_n_Sm.reflexivity.
55 qed.
56
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.
61 qed.
62
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.
65 simplify.unfold lt.
66 apply (trans_le ? ((S(S O))*(S n1))).
67 simplify.
68 rewrite < plus_n_Sm.apply le_S_S.apply le_S_S.
69 rewrite < sym_plus.
70 apply le_plus_n.
71 apply le_times.assumption.assumption.
72 qed.
73
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.
79 apply le_O_n.
80 qed.
81
82 theorem injective_exp_r: \forall n:nat. (S O) < n \to 
83 injective nat nat (\lambda m:nat. n \sup m).
84 simplify.intros 4.
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.
89 intros.apply eq_f.
90 apply H1.
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.
94 assumption.
95 intros 2.
96 apply (nat_case n).
97 intros.apply False_ind.apply (not_le_Sn_O O H3).
98 intros.
99 apply (inj_times_r m1).assumption.
100 qed.
101
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
104 injective_exp_r.
105
106 theorem le_exp: \forall n,m,p:nat. O < p \to n \le m \to exp p n \le exp p m.
107 apply nat_elim2
108   [intros.
109    apply lt_O_exp.assumption
110   |intros.
111    apply False_ind.
112    apply (le_to_not_lt ? ? ? H1).
113    apply le_O_n
114   |intros.
115    simplify.
116    apply le_times
117     [apply le_n
118     |apply H[assumption|apply le_S_S_to_le.assumption]
119     ]
120   ]
121 qed.
122
123 theorem lt_exp: \forall n,m,p:nat. S O < p \to n < m \to exp p n < exp p m.
124 apply nat_elim2
125   [intros.
126    apply (lt_O_n_elim ? H1).intro.
127    simplify.unfold lt.
128    rewrite > times_n_SO.
129    apply le_times
130     [assumption
131     |apply lt_O_exp.
132      apply (trans_lt ? (S O))[apply le_n|assumption]
133     ]
134   |intros.
135    apply False_ind.
136    apply (le_to_not_lt ? ? ? H1).
137    apply le_O_n
138   |intros.simplify.
139    apply lt_times_r1
140     [apply (trans_lt ? (S O))[apply le_n|assumption]
141     |apply H
142       [apply H1
143       |apply le_S_S_to_le.assumption
144       ]
145     ]
146   ]
147 qed.
148
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.
151 intro.
152 apply nat_elim2;intros
153   [apply le_O_n
154   |apply False_ind.
155    apply (le_to_not_lt ? ? H1).
156    simplify.
157    rewrite > times_n_SO.
158    apply lt_to_le_to_lt_times
159     [assumption
160     |apply lt_O_exp.apply lt_to_le.assumption
161     |apply lt_O_exp.apply lt_to_le.assumption
162     ]
163   |simplify in H2.
164    apply le_S_S.
165    apply H
166     [assumption
167     |apply (le_times_to_le a)
168       [apply lt_to_le.assumption|assumption]
169     ]
170   ]
171 qed.
172
173 theorem lt_exp_to_lt: 
174 \forall a,n,m. S O < a \to exp a n < exp a m \to n < m.
175 intros.
176 elim (le_to_or_lt_eq n m)
177   [assumption
178   |apply False_ind.
179    apply (lt_to_not_eq ? ? H1).
180    rewrite < H2.
181    reflexivity
182   |apply (le_exp_to_le a)
183     [assumption
184     |apply lt_to_le.
185      assumption
186     ]
187   ]
188 qed.
189      
190    
191    
192