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 =
28 (cic:/matita/demo/power_derivative/R0.con).
29 interpretation "Nzero" 'zero =
30 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)).
32 notation "1" with precedence 89
34 interpretation "Rone" 'one =
35 (cic:/matita/demo/power_derivative/R1.con).
36 interpretation "None" 'one =
37 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2)
38 cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)).
40 interpretation "Rplus" 'plus x y =
41 (cic:/matita/demo/power_derivative/Rplus.con x y).
43 interpretation "Rmult" 'middot x y =
44 (cic:/matita/demo/power_derivative/Rmult.con x y).
47 λf,g:R→R.λx:R.f x + g x.
50 λf,g:R→R.λx:R.f x · g x.
52 interpretation "Fplus" 'plus x y =
53 (cic:/matita/demo/power_derivative/Fplus.con x y).
54 interpretation "Fmult" 'middot x y =
55 (cic:/matita/demo/power_derivative/Fmult.con x y).
57 notation "2" with precedence 89
59 interpretation "Rtwo" 'two =
60 (cic:/matita/demo/power_derivative/Rplus.con
61 cic:/matita/demo/power_derivative/R1.con
62 cic:/matita/demo/power_derivative/R1.con).
63 interpretation "Ntwo" 'two =
64 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2)
65 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2)
66 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)))).
68 let rec Rpower (x:R) (n:nat) on n ≝
71 | S n ⇒ x · (Rpower x n)
74 interpretation "Rpower" 'exp x n =
75 (cic:/matita/demo/power_derivative/Rpower.con x n).
77 let rec inj (n:nat) on n : R ≝
89 axiom Rplus_Rzero_x: ∀x:R.0+x=x.
90 axiom Rplus_comm: symmetric ? Rplus.
91 axiom Rplus_assoc: associative ? Rplus.
92 axiom Rmult_Rone_x: ∀x:R.1 · x=x.
93 axiom Rmult_Rzero_x: ∀x:R.0 · x=0.
94 axiom Rmult_assoc: associative ? Rmult.
95 axiom Rmult_comm: symmetric ? Rmult.
96 axiom Rmult_Rplus_distr: distributive ? Rmult Rplus.
98 alias symbol "middot" = "Rmult".
99 alias symbol "plus" = "natural plus".
104 definition costante : nat → R → R ≝
107 coercion costante with 1.
109 axiom f_eq_extensional:
110 ∀f,g:R→R.(∀x:R.f x = g x) → f=g.
112 lemma Fmult_one_f: ∀f:R→R.1·f=f.
116 apply f_eq_extensional;
121 lemma Fmult_zero_f: ∀f:R→R.0·f=0.
125 apply f_eq_extensional;
130 lemma Fmult_commutative: symmetric ? Fmult.
134 apply f_eq_extensional;
139 lemma Fmult_associative: associative ? Fmult.
144 apply f_eq_extensional;
149 lemma Fmult_Fplus_distr: distributive ? Fmult Fplus.
154 apply f_eq_extensional;
160 lemma monomio_product:
161 ∀n,m.monomio (n+m) = monomio n · monomio m.
168 apply f_eq_extensional;
172 apply f_eq_extensional;
174 cut (x\sup (n1+m) = x \sup n1 · x \sup m);
177 | change in ⊢ (? ? % ?) with ((λx:R.x\sup(n1+m)) x);
185 ∀n,m.costante n + costante m = costante (n+m).
189 apply f_eq_extensional;
220 axiom derivative: (R→R) → R → R.
222 notation "hvbox('D'[f])"
223 non associative with precedence 90
224 for @{ 'derivative $f }.
226 interpretation "Rderivative" 'derivative f =
227 (cic:/matita/demo/power_derivative/derivative.con f).
229 notation "hvbox('x' \sup n)"
230 non associative with precedence 60
231 for @{ 'monomio $n }.
233 notation "hvbox('x')"
234 non associative with precedence 60
237 interpretation "Rmonomio" 'monomio n =
238 (cic:/matita/demo/power_derivative/monomio.con n).
240 axiom derivative_x0: D[x \sup 0] = 0.
241 axiom derivative_x1: D[x] = 1.
242 axiom derivative_mult: ∀f,g:R→R. D[f·g] = D[f]·g + f·D[g].
244 alias symbol "middot" = "Fmult".
246 theorem derivative_power: ∀n:nat. D[x \sup n] = n·x \sup (pred n).
248 (*we proceed by induction on n to prove
249 (D[x \sup n] = n · x \sup (pred n)).*)
252 the thesis becomes (D[x \sup 0] = 0·x \sup (pred 0)).
255 by induction hypothesis we know
256 (D[x \sup m] = m·x \sup (pred m)) (H).
258 (D[x \sup (1+m)] = (1+m) · x \sup m).
260 (m · (x \sup (1+ pred m)) = m · x \sup m) (Ppred).
261 we proved (0 < m ∨ 0=m) (cases).
262 we proceed by induction on cases
263 to prove (m · (x \sup (1+ pred m)) = m · x \sup m).
265 suppose (0 < m) (m_pos).
266 using (S_pred ? m_pos) we proved (m = 1 + pred m) (H1).
269 suppose (0=m) (m_zero).
270 by m_zero, Fmult_zero_f done.
274 = (D[x] · x \sup m + x · D[x \sup m]).
275 = (x \sup m + x · (m · x \sup (pred m))) timeout=30.
276 = (x \sup m + m · (x \sup (1 + pred m))).
277 = (x \sup m + m · x \sup m).
278 = ((1+m) · x \sup m) timeout=30 by Fmult_one_f, Fmult_commutative, Fmult_Fplus_distr, costante_sum
283 notation "hvbox(\frac 'd' ('d' ident i) break p)"
284 right associative with precedence 90
285 for @{ 'derivative ${default
286 @{\lambda ${ident i} : $ty. $p)}
287 @{\lambda ${ident i} . $p}}}.
289 interpretation "Rderivative" 'derivative \eta.f =
290 (cic:/matita/demo/power_derivative/derivative.con f).
293 notation "hvbox(\frac 'd' ('d' 'x') break p)" with precedence 90
294 for @{ 'derivative $p}.
296 interpretation "Rderivative" 'derivative f =
297 (cic:/matita/demo/power_derivative/derivative.con f).
299 theorem derivative_power': ∀n:nat. D[x \sup (1+n)] = (1+n) · x \sup n.
301 (*we proceed by induction on n to prove
302 (D[x \sup (1+n)] = (1+n) · x \sup n).*) elim n 0.
304 the thesis becomes (D[x \sup 1] = 1 · x \sup 0).
307 by induction hypothesis we know
308 (D[x \sup (1+m)] = (1+m) · x \sup m) (H).
310 (D[x \sup (2+m)] = (2+m) · x \sup (1+m)).
313 = (D[x · x \sup (1+m)]).
314 = (D[x] · x \sup (1+m) + x · D[x \sup (1+m)]).
315 = (x \sup (1+m) + x · (costante (1+m) · x \sup m)).
316 = (x \sup (1+m) + costante (1+m) · x \sup (1+m)).
317 = ((2+m) · x \sup (1+m)) timeout=30 by Fmult_one_f, Fmult_commutative,
318 Fmult_Fplus_distr, assoc_plus, plus_n_SO, costante_sum