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 set "baseuri" "cic:/matita/demo/power_derivative".
17 include "nat/plus.ma".
18 include "nat/orders.ma".
19 include "nat/compare.ma".
27 notation "0" with precedence 89
29 interpretation "Rzero" 'zero =
30 (cic:/matita/demo/power_derivative/R0.con).
31 interpretation "Nzero" 'zero =
32 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)).
34 notation "1" with precedence 89
36 interpretation "Rone" 'one =
37 (cic:/matita/demo/power_derivative/R1.con).
38 interpretation "None" 'one =
39 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2)
40 cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)).
42 interpretation "Rplus" 'plus x y =
43 (cic:/matita/demo/power_derivative/Rplus.con x y).
45 notation "hvbox(a break \middot b)"
46 left associative with precedence 55
47 for @{ 'times $a $b }.
49 interpretation "Rmult" 'times x y =
50 (cic:/matita/demo/power_derivative/Rmult.con x y).
53 λf,g:R→R.λx:R.f x + g x.
56 λf,g:R→R.λx:R.f x · g x.
58 interpretation "Fplus" 'plus x y =
59 (cic:/matita/demo/power_derivative/Fplus.con x y).
60 interpretation "Fmult" 'times x y =
61 (cic:/matita/demo/power_derivative/Fmult.con x y).
63 notation "2" with precedence 89
65 interpretation "Rtwo" 'two =
66 (cic:/matita/demo/power_derivative/Rplus.con
67 cic:/matita/demo/power_derivative/R1.con
68 cic:/matita/demo/power_derivative/R1.con).
69 interpretation "Ntwo" 'two =
70 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2)
71 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2)
72 (cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)))).
74 let rec Rpower (x:R) (n:nat) on n ≝
77 | S n ⇒ x · (Rpower x n)
80 interpretation "Rpower" 'exp x n =
81 (cic:/matita/demo/power_derivative/Rpower.con x n).
83 let rec inj (n:nat) on n : R ≝
93 coercion cic:/matita/demo/power_derivative/inj.con.
95 axiom Rplus_Rzero_x: ∀x:R.0+x=x.
96 axiom Rplus_comm: symmetric ? Rplus.
97 axiom Rplus_assoc: associative ? Rplus.
98 axiom Rmult_Rone_x: ∀x:R.1*x=x.
99 axiom Rmult_Rzero_x: ∀x:R.0*x=0.
100 axiom Rmult_assoc: associative ? Rmult.
101 axiom Rmult_comm: symmetric ? Rmult.
102 axiom Rmult_Rplus_distr: distributive ? Rmult Rplus.
104 alias symbol "times" = "Rmult".
105 alias symbol "plus" = "natural plus".
110 definition costante : nat → R → R ≝
113 coercion cic:/matita/demo/power_derivative/costante.con 1.
115 axiom f_eq_extensional:
116 ∀f,g:R→R.(∀x:R.f x = g x) → f=g.
118 lemma Fmult_one_f: ∀f:R→R.1·f=f.
122 apply f_eq_extensional;
127 lemma Fmult_zero_f: ∀f:R→R.0·f=0.
131 apply f_eq_extensional;
136 lemma Fmult_commutative: symmetric ? Fmult.
140 apply f_eq_extensional;
145 lemma Fmult_associative: associative ? Fmult.
150 apply f_eq_extensional;
155 lemma Fmult_Fplus_distr: distributive ? Fmult Fplus.
160 apply f_eq_extensional;
166 lemma monomio_product:
167 ∀n,m.monomio (n+m) = monomio n · monomio m.
174 apply f_eq_extensional;
178 apply f_eq_extensional;
180 cut (x\sup (n1+m) = x \sup n1 · x \sup m);
183 | change in ⊢ (? ? % ?) with ((λx:R.x\sup(n1+m)) x);
191 ∀n,m.costante n + costante m = costante (n+m).
195 apply f_eq_extensional;
226 axiom derivative: (R→R) → R → R.
228 notation "hvbox('D'[f])"
229 non associative with precedence 90
230 for @{ 'derivative $f }.
232 interpretation "Rderivative" 'derivative f =
233 (cic:/matita/demo/power_derivative/derivative.con f).
235 notation "hvbox('x' \sup n)"
236 non associative with precedence 60
237 for @{ 'monomio $n }.
239 notation "hvbox('x')"
240 non associative with precedence 60
243 interpretation "Rmonomio" 'monomio n =
244 (cic:/matita/demo/power_derivative/monomio.con n).
246 axiom derivative_x0: D[x \sup 0] = 0.
247 axiom derivative_x1: D[x] = 1.
248 axiom derivative_mult: ∀f,g:R→R. D[f·g] = D[f]·g + f·D[g].
250 alias symbol "times" = "Fmult".
252 theorem derivative_power: ∀n:nat. D[x \sup n] = n·x \sup (pred n).
254 (*we proceed by induction on n to prove
255 (D[x \sup n] = n · x \sup (pred n)).*)
258 the thesis becomes (D[x \sup 0] = 0·x \sup (pred 0)).
262 by induction hypothesis we know
263 (D[x \sup m] = m·x \sup (pred m)) (H).
265 (D[x \sup (1+m)] = (1+m) · x \sup m).
267 (m · (x \sup (1+ pred m)) = m · x \sup m) (Ppred).
268 by _ we proved (0 < m ∨ 0=m) (cases).
269 we proceed by induction on cases
270 to prove (m · (x \sup (1+ pred m)) = m · x \sup m).
272 suppose (0 < m) (m_pos).
273 by (S_pred m m_pos) we proved (m = 1 + pred m) (H1).
277 suppose (0=m) (m_zero). by _ done.
280 = (D[x · x \sup m]) by _.
281 = (D[x] · x \sup m + x · D[x \sup m]) by _.
282 = (x \sup m + x · (m · x \sup (pred m))) by _.
284 = (x \sup m + m · (x \sup (1 + pred m))) by _.
285 = (x \sup m + m · x \sup m) by _.
286 = ((1+m) · x \sup m) by _ (timeout=120)
291 notation "hvbox(\frac 'd' ('d' ident i) break p)"
292 right associative with precedence 90
293 for @{ 'derivative ${default
294 @{\lambda ${ident i} : $ty. $p)}
295 @{\lambda ${ident i} . $p}}}.
297 interpretation "Rderivative" 'derivative \eta.f =
298 (cic:/matita/demo/power_derivative/derivative.con f).
301 notation "hvbox(\frac 'd' ('d' 'x') break p)"
302 right associative with precedence 90
303 for @{ 'derivative $p}.
305 interpretation "Rderivative" 'derivative f =
306 (cic:/matita/demo/power_derivative/derivative.con f).
308 theorem derivative_power': ∀n:nat. D[x \sup (1+n)] = (1+n) · x \sup n.
310 (*we proceed by induction on n to prove
311 (D[x \sup (1+n)] = (1+n) · x \sup n).*) elim n 0.
313 the thesis becomes (D[x \sup 1] = 1 · x \sup 0).
317 by induction hypothesis we know
318 (D[x \sup (1+m)] = (1+m) · x \sup m) (H).
320 (D[x \sup (2+m)] = (2+m) · x \sup (1+m)).
323 = (D[x · x \sup (1+m)]) by _.
324 = (D[x] · x \sup (1+m) + x · D[x \sup (1+m)]) by _.
325 = (x \sup (1+m) + x · (costante (1+m) · x \sup m)) by _.
327 = (x \sup (1+m) + costante (1+m) · x \sup (1+m)) by _.
328 = (x \sup (1+m) · (costante (2 + m))) by _