1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "nat/plus.ma".
16 include "nat/orders.ma".
17 include "nat/compare.ma".
25 notation "0" with precedence 89
27 interpretation "Rzero" 'zero = (R0).
28 interpretation "Nzero" 'zero = (O).
30 notation "1" with precedence 89
32 interpretation "Rone" 'one = (R1).
33 interpretation "None" 'one = (S O).
35 interpretation "Rplus" 'plus x y = (Rplus x y).
37 interpretation "Rmult" 'middot x y = (Rmult x y).
40 λf,g:R→R.λx:R.f x + g x.
43 λf,g:R→R.λx:R.f x · g x.
45 interpretation "Fplus" 'plus x y = (Fplus x y).
46 interpretation "Fmult" 'middot x y = (Fmult x y).
48 notation "2" with precedence 89
50 interpretation "Rtwo" 'two = (Rplus R1 R1).
51 interpretation "Ntwo" 'two = (S (S O)).
53 let rec Rpower (x:R) (n:nat) on n ≝
56 | S n ⇒ x · (Rpower x n)
59 interpretation "Rpower" 'exp x n = (Rpower x n).
61 let rec inj (n:nat) on n : R ≝
73 axiom Rplus_Rzero_x: ∀x:R.0+x=x.
74 axiom Rplus_comm: symmetric ? Rplus.
75 axiom Rplus_assoc: associative ? Rplus.
76 axiom Rmult_Rone_x: ∀x:R.1 · x=x.
77 axiom Rmult_Rzero_x: ∀x:R.0 · x=0.
78 axiom Rmult_assoc: associative ? Rmult.
79 axiom Rmult_comm: symmetric ? Rmult.
80 axiom Rmult_Rplus_distr: distributive ? Rmult Rplus.
82 alias symbol "middot" = "Rmult".
83 alias symbol "plus" = "natural plus".
88 definition costante : nat → R → R ≝
91 coercion costante with 1.
93 axiom f_eq_extensional:
94 ∀f,g:R→R.(∀x:R.f x = g x) → f=g.
96 lemma Fmult_one_f: ∀f:R→R.1·f=f.
100 apply f_eq_extensional;
105 lemma Fmult_zero_f: ∀f:R→R.0·f=0.
109 apply f_eq_extensional;
114 lemma Fmult_commutative: symmetric ? Fmult.
118 apply f_eq_extensional;
123 lemma Fmult_associative: associative ? Fmult.
128 apply f_eq_extensional;
133 lemma Fmult_Fplus_distr: distributive ? Fmult Fplus.
138 apply f_eq_extensional;
144 lemma monomio_product:
145 ∀n,m.monomio (n+m) = monomio n · monomio m.
152 apply f_eq_extensional;
156 apply f_eq_extensional;
158 cut (x\sup (n1+m) = x \sup n1 · x \sup m);
161 | change in ⊢ (? ? % ?) with ((λx:R.x\sup(n1+m)) x);
169 ∀n,m.costante n + costante m = costante (n+m).
173 apply f_eq_extensional;
204 axiom derivative: (R→R) → R → R.
206 notation "hvbox('D'[f])"
207 non associative with precedence 90
208 for @{ 'derivative $f }.
210 interpretation "Rderivative" 'derivative f = (derivative f).
212 (* FG: we definitely do not want 'x' as a keyward!
213 * Any file that includes this one can not use 'x' as an identifier
215 notation "hvbox('X' \sup n)"
216 non associative with precedence 60
217 for @{ 'monomio $n }.
219 notation "hvbox('X')"
220 non associative with precedence 60
223 interpretation "Rmonomio" 'monomio n = (monomio n).
225 axiom derivative_x0: D[X \sup 0] = 0.
226 axiom derivative_x1: D[X] = 1.
228 axiom derivative_mult: ∀f,g:R→R. D[f·g] = D[f]·g + f·D[g].
230 alias symbol "middot" = "Fmult".
232 theorem derivative_power: ∀n:nat. D[X \sup n] = n·X \sup (pred n).
234 (*we proceed by induction on n to prove
235 (D[X \sup n] = n · X \sup (pred n)).*)
238 the thesis becomes (D[X \sup 0] = 0·X \sup (pred 0)).
241 by induction hypothesis we know
242 (D[X \sup m] = m·X \sup (pred m)) (H).
244 (D[X \sup (1+m)] = (1+m) · X \sup m).
246 (m · (X \sup (1+ pred m)) = m · X \sup m) (Ppred).
248 we proved (0 < m ∨ 0=m) (cases).
249 we proceed by induction on cases
250 to prove (m · (X \sup (1+ pred m)) = m · X \sup m).
252 suppose (0 < m) (m_pos).
253 using (S_pred ? m_pos) we proved (m = 1 + pred m) (H1).
256 suppose (0=m) (m_zero).
257 by m_zero, Fmult_zero_f done.
261 = (D[X] · X \sup m + X · D[X \sup m]).
262 = (X \sup m + X · (m · X \sup (pred m))).
263 lapply depth=0 Fmult_associative;
264 lapply depth=0 Fmult_commutative;
265 = (X \sup m + m · (X · X \sup (pred m))) by Fmult_associative, Fmult_commutative.
266 = (X \sup m + m · (X \sup (1 + pred m))).
267 = (X \sup m + m · X \sup m).
268 = ((1+m) · X \sup m) by Fmult_one_f, Fmult_commutative, Fmult_Fplus_distr, costante_sum
273 notation "hvbox(\frac 'd' ('d' ident i) break p)"
274 right associative with precedence 90
275 for @{ 'derivative ${default
276 @{\lambda ${ident i} : $ty. $p)}
277 @{\lambda ${ident i} . $p}}}.
279 interpretation "Rderivative" 'derivative \eta.f = (derivative f).
282 notation "hvbox(\frac 'd' ('d' 'X') break p)" with precedence 90
283 for @{ 'derivative $p}.
285 interpretation "Rderivative" 'derivative f = (derivative f).
287 theorem derivative_power': ∀n:nat. D[X \sup (1+n)] = (1+n) · X \sup n.
289 (*we proceed by induction on n to prove
290 (D[X \sup (1+n)] = (1+n) · X \sup n).*) elim n 0.
292 the thesis becomes (D[X \sup 1] = 1 · X \sup 0).
295 by induction hypothesis we know
296 (D[X \sup (1+m)] = (1+m) · X \sup m) (H).
298 (D[X \sup (2+m)] = (2+m) · X \sup (1+m)).
301 = (D[X · X \sup (1+m)]).
302 = (D[X] · X \sup (1+m) + X · D[X \sup (1+m)]).
303 = (X \sup (1+m) + X · (costante (1+m) · X \sup m)).
304 = (X \sup (1+m) + costante (1+m) · X \sup (1+m)).
305 = ((2+m) · X \sup (1+m)) timeout=30 by Fmult_one_f, Fmult_commutative,
306 Fmult_Fplus_distr, assoc_plus, plus_n_SO, costante_sum