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 notation "hvbox('x' \sup n)"
213 non associative with precedence 60
214 for @{ 'monomio $n }.
216 notation "hvbox('x')"
217 non associative with precedence 60
220 interpretation "Rmonomio" 'monomio n = (monomio n).
222 axiom derivative_x0: D[x \sup 0] = 0.
223 axiom derivative_x1: D[x] = 1.
224 axiom derivative_mult: ∀f,g:R→R. D[f·g] = D[f]·g + f·D[g].
226 alias symbol "middot" = "Fmult".
228 theorem derivative_power: ∀n:nat. D[x \sup n] = n·x \sup (pred n).
230 (*we proceed by induction on n to prove
231 (D[x \sup n] = n · x \sup (pred n)).*)
234 the thesis becomes (D[x \sup 0] = 0·x \sup (pred 0)).
237 by induction hypothesis we know
238 (D[x \sup m] = m·x \sup (pred m)) (H).
240 (D[x \sup (1+m)] = (1+m) · x \sup m).
242 (m · (x \sup (1+ pred m)) = m · x \sup m) (Ppred).
243 we proved (0 < m ∨ 0=m) (cases).
244 we proceed by induction on cases
245 to prove (m · (x \sup (1+ pred m)) = m · x \sup m).
247 suppose (0 < m) (m_pos).
248 using (S_pred ? m_pos) we proved (m = 1 + pred m) (H1).
251 suppose (0=m) (m_zero).
252 by m_zero, Fmult_zero_f done.
256 = (D[x] · x \sup m + x · D[x \sup m]).
257 = (x \sup m + x · (m · x \sup (pred m))) timeout=30.
258 = (x \sup m + m · (x \sup (1 + pred m))).
259 = (x \sup m + m · x \sup m).
260 = ((1+m) · x \sup m) timeout=30 by Fmult_one_f, Fmult_commutative, Fmult_Fplus_distr, costante_sum
265 notation "hvbox(\frac 'd' ('d' ident i) break p)"
266 right associative with precedence 90
267 for @{ 'derivative ${default
268 @{\lambda ${ident i} : $ty. $p)}
269 @{\lambda ${ident i} . $p}}}.
271 interpretation "Rderivative" 'derivative \eta.f = (derivative f).
274 notation "hvbox(\frac 'd' ('d' 'x') break p)" with precedence 90
275 for @{ 'derivative $p}.
277 interpretation "Rderivative" 'derivative f = (derivative f).
279 theorem derivative_power': ∀n:nat. D[x \sup (1+n)] = (1+n) · x \sup n.
281 (*we proceed by induction on n to prove
282 (D[x \sup (1+n)] = (1+n) · x \sup n).*) elim n 0.
284 the thesis becomes (D[x \sup 1] = 1 · x \sup 0).
287 by induction hypothesis we know
288 (D[x \sup (1+m)] = (1+m) · x \sup m) (H).
290 (D[x \sup (2+m)] = (2+m) · x \sup (1+m)).
293 = (D[x · x \sup (1+m)]).
294 = (D[x] · x \sup (1+m) + x · D[x \sup (1+m)]).
295 = (x \sup (1+m) + x · (costante (1+m) · x \sup m)).
296 = (x \sup (1+m) + costante (1+m) · x \sup (1+m)).
297 = ((2+m) · x \sup (1+m)) timeout=30 by Fmult_one_f, Fmult_commutative,
298 Fmult_Fplus_distr, assoc_plus, plus_n_SO, costante_sum