X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Flibrary%2Fdemo%2Fpower_derivative.ma;h=a425dfcc357783ee52a23f8215be3d91265d29b5;hb=070b44c9c2344967ca8c4531909614a0d4da2fbe;hp=879f55d7e4976227c48756d39a626a1120d12147;hpb=9a27004d7665a5659d1959392d3d0ff5b23b3603;p=helm.git diff --git a/helm/software/matita/library/demo/power_derivative.ma b/helm/software/matita/library/demo/power_derivative.ma index 879f55d7e..a425dfcc3 100644 --- a/helm/software/matita/library/demo/power_derivative.ma +++ b/helm/software/matita/library/demo/power_derivative.ma @@ -12,8 +12,6 @@ (* *) (**************************************************************************) -set "baseuri" "cic:/matita/demo/power_derivative". - include "nat/plus.ma". include "nat/orders.ma". include "nat/compare.ma". @@ -26,54 +24,39 @@ axiom Rmult: R→R→R. notation "0" with precedence 89 for @{ 'zero }. -interpretation "Rzero" 'zero = - (cic:/matita/demo/power_derivative/R0.con). -interpretation "Nzero" 'zero = - (cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)). +interpretation "Rzero" 'zero = (R0). +interpretation "Nzero" 'zero = (O). notation "1" with precedence 89 for @{ 'one }. -interpretation "Rone" 'one = - (cic:/matita/demo/power_derivative/R1.con). -interpretation "None" 'one = - (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2) - cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)). +interpretation "Rone" 'one = (R1). +interpretation "None" 'one = (S O). + +interpretation "Rplus" 'plus x y = (Rplus x y). -interpretation "Rplus" 'plus x y = - (cic:/matita/demo/power_derivative/Rplus.con x y). -interpretation "Rmult" 'times x y = - (cic:/matita/demo/power_derivative/Rmult.con x y). +interpretation "Rmult" 'middot x y = (Rmult x y). definition Fplus ≝ λf,g:R→R.λx:R.f x + g x. definition Fmult ≝ - λf,g:R→R.λx:R.f x * g x. + λf,g:R→R.λx:R.f x · g x. -interpretation "Fplus" 'plus x y = - (cic:/matita/demo/power_derivative/Fplus.con x y). -interpretation "Fmult" 'times x y = - (cic:/matita/demo/power_derivative/Fmult.con x y). +interpretation "Fplus" 'plus x y = (Fplus x y). +interpretation "Fmult" 'middot x y = (Fmult x y). notation "2" with precedence 89 for @{ 'two }. -interpretation "Rtwo" 'two = - (cic:/matita/demo/power_derivative/Rplus.con - cic:/matita/demo/power_derivative/R1.con - cic:/matita/demo/power_derivative/R1.con). -interpretation "Ntwo" 'two = - (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2) - (cic:/matita/nat/nat/nat.ind#xpointer(1/1/2) - (cic:/matita/nat/nat/nat.ind#xpointer(1/1/1)))). +interpretation "Rtwo" 'two = (Rplus R1 R1). +interpretation "Ntwo" 'two = (S (S O)). let rec Rpower (x:R) (n:nat) on n ≝ match n with [ O ⇒ 1 - | S n ⇒ x * (Rpower x n) + | S n ⇒ x · (Rpower x n) ]. -interpretation "Rpower" 'exp x n = - (cic:/matita/demo/power_derivative/Rpower.con x n). +interpretation "Rpower" 'exp x n = (Rpower x n). let rec inj (n:nat) on n : R ≝ match n with @@ -85,18 +68,18 @@ let rec inj (n:nat) on n : R ≝ ] ]. -coercion cic:/matita/demo/power_derivative/inj.con. +coercion inj. axiom Rplus_Rzero_x: ∀x:R.0+x=x. axiom Rplus_comm: symmetric ? Rplus. axiom Rplus_assoc: associative ? Rplus. -axiom Rmult_Rone_x: ∀x:R.1*x=x. -axiom Rmult_Rzero_x: ∀x:R.0*x=0. +axiom Rmult_Rone_x: ∀x:R.1 · x=x. +axiom Rmult_Rzero_x: ∀x:R.0 · x=0. axiom Rmult_assoc: associative ? Rmult. axiom Rmult_comm: symmetric ? Rmult. axiom Rmult_Rplus_distr: distributive ? Rmult Rplus. -alias symbol "times" = "Rmult". +alias symbol "middot" = "Rmult". alias symbol "plus" = "natural plus". definition monomio ≝ @@ -105,27 +88,27 @@ definition monomio ≝ definition costante : nat → R → R ≝ λa:nat.λx:R.inj a. -coercion cic:/matita/demo/power_derivative/costante.con 1. +coercion costante with 1. axiom f_eq_extensional: ∀f,g:R→R.(∀x:R.f x = g x) → f=g. -lemma Fmult_one_f: ∀f:R→R.1*f=f. +lemma Fmult_one_f: ∀f:R→R.1·f=f. intro; unfold Fmult; simplify; apply f_eq_extensional; intro; - auto. + autobatch. qed. -lemma Fmult_zero_f: ∀f:R→R.0*f=0. +lemma Fmult_zero_f: ∀f:R→R.0·f=0. intro; unfold Fmult; simplify; apply f_eq_extensional; intro; - auto. + autobatch. qed. lemma Fmult_commutative: symmetric ? Fmult. @@ -134,7 +117,7 @@ lemma Fmult_commutative: symmetric ? Fmult. unfold Fmult; apply f_eq_extensional; intros; - auto. + autobatch. qed. lemma Fmult_associative: associative ? Fmult. @@ -144,7 +127,7 @@ lemma Fmult_associative: associative ? Fmult. unfold Fmult; apply f_eq_extensional; intros; - auto. + autobatch. qed. lemma Fmult_Fplus_distr: distributive ? Fmult Fplus. @@ -155,11 +138,11 @@ lemma Fmult_Fplus_distr: distributive ? Fmult Fplus. apply f_eq_extensional; intros; simplify; - auto. + autobatch. qed. lemma monomio_product: - ∀n,m.monomio (n+m) = monomio n * monomio m. + ∀n,m.monomio (n+m) = monomio n · monomio m. intros; unfold monomio; unfold Fmult; @@ -168,14 +151,14 @@ lemma monomio_product: [ simplify; apply f_eq_extensional; intro; - auto + autobatch | simplify; apply f_eq_extensional; intro; - cut (x\sup (n1+m) = x \sup n1 * x \sup m); + cut (x\sup (n1+m) = x \sup n1 · x \sup m); [ rewrite > Hcut; - auto - | change in ⊢ (? ? % ?) with ((λx:R.(x)\sup(n1+m)) x); + autobatch + | change in ⊢ (? ? % ?) with ((λx:R.x\sup(n1+m)) x); rewrite > H; reflexivity ] @@ -191,7 +174,7 @@ lemma costante_sum: intros; elim n; [ simplify; - auto + autobatch | simplify; clear x; clear H; @@ -200,19 +183,19 @@ lemma costante_sum: [ simplify; elim m; [ simplify; - auto + autobatch | simplify; rewrite < H; - auto + autobatch ] | simplify; rewrite < H; clear H; elim n; [ simplify; - auto + autobatch | simplify; - auto + autobatch ] ] ]. @@ -224,60 +207,65 @@ notation "hvbox('D'[f])" non associative with precedence 90 for @{ 'derivative $f }. -interpretation "Rderivative" 'derivative f = - (cic:/matita/demo/power_derivative/derivative.con f). +interpretation "Rderivative" 'derivative f = (derivative f). -notation "hvbox('x' \sup n)" +(* FG: we definitely do not want 'x' as a keyward! + * Any file that includes this one can not use 'x' as an identifier + *) +notation "hvbox('X' \sup n)" non associative with precedence 60 for @{ 'monomio $n }. -notation "hvbox('x')" +notation "hvbox('X')" non associative with precedence 60 for @{ 'monomio 1 }. -interpretation "Rmonomio" 'monomio n = - (cic:/matita/demo/power_derivative/monomio.con n). +interpretation "Rmonomio" 'monomio n = (monomio n). -axiom derivative_x0: D[x \sup 0] = 0. -axiom derivative_x1: D[x] = 1. -axiom derivative_mult: ∀f,g:R→R. D[f*g] = D[f]*g + f*D[g]. +axiom derivative_x0: D[X \sup 0] = 0. +axiom derivative_x1: D[X] = 1. -alias symbol "times" = "Fmult". +axiom derivative_mult: ∀f,g:R→R. D[f·g] = D[f]·g + f·D[g]. -theorem derivative_power: ∀n:nat. D[x \sup n] = n*x \sup (pred n). +alias symbol "middot" = "Fmult". + +theorem derivative_power: ∀n:nat. D[X \sup n] = n·X \sup (pred n). assume n:nat. - we proceed by induction on n to prove - (D[x \sup n] = n*x \sup (pred n)). + (*we proceed by induction on n to prove + (D[X \sup n] = n · X \sup (pred n)).*) + elim n 0. case O. - the thesis becomes (D[x \sup 0] = 0*x \sup (pred 0)). - by _ + the thesis becomes (D[X \sup 0] = 0·X \sup (pred 0)). done. case S (m:nat). by induction hypothesis we know - (D[x \sup m] = m*x \sup (pred m)) (H). + (D[X \sup m] = m·X \sup (pred m)) (H). the thesis becomes - (D[x \sup (1+m)] = (1+m)*x \sup m). + (D[X \sup (1+m)] = (1+m) · X \sup m). we need to prove - (m * (x \sup (1+ pred m)) = m * x \sup m) (Ppred). - by _ we proved (0 < m ∨ 0=m) (cases). + (m · (X \sup (1+ pred m)) = m · X \sup m) (Ppred). + lapply depth=0 le_n; + we proved (0 < m ∨ 0=m) (cases). we proceed by induction on cases - to prove (m * (x \sup (1+ pred m)) = m * x \sup m). + to prove (m · (X \sup (1+ pred m)) = m · X \sup m). case left. suppose (0 < m) (m_pos). - by (S_pred m m_pos) we proved (m = 1 + pred m) (H1). - by _ - done. + using (S_pred ? m_pos) we proved (m = 1 + pred m) (H1). + by H1 done. case right. - suppose (0=m) (m_zero). by _ done. + suppose (0=m) (m_zero). + by m_zero, Fmult_zero_f done. conclude - (D[x \sup (1+m)]) - = (D[x * x \sup m]) by _. - = (D[x] * x \sup m + x * D[x \sup m]) by _. - = (x \sup m + x * (m * x \sup (pred m))) by _. -clear H. - = (x \sup m + m * (x \sup (1 + pred m))) by _. - = (x \sup m + m * x \sup m) by _. - = ((1+m)*x \sup m) by _ (timeout=30) + (D[X \sup (1+m)]) + = (D[X · X \sup m]). + = (D[X] · X \sup m + X · D[X \sup m]). + = (X \sup m + X · (m · X \sup (pred m))). + lapply depth=0 Fmult_associative; + lapply depth=0 Fmult_commutative; + = (X \sup m + m · (X · X \sup (pred m))) by Fmult_associative, Fmult_commutative. + = (X \sup m + m · (X \sup (1 + pred m))). + = (X \sup m + m · X \sup m). + = ((1+m) · X \sup m) by Fmult_one_f, Fmult_commutative, Fmult_Fplus_distr, costante_sum done. qed. @@ -288,37 +276,33 @@ for @{ 'derivative ${default @{\lambda ${ident i} : $ty. $p)} @{\lambda ${ident i} . $p}}}. -interpretation "Rderivative" 'derivative \eta.f = - (cic:/matita/demo/power_derivative/derivative.con f). +interpretation "Rderivative" 'derivative \eta.f = (derivative f). *) -notation "hvbox(\frac 'd' ('d' 'x') break p)" - right associative with precedence 90 +notation "hvbox(\frac 'd' ('d' 'X') break p)" with precedence 90 for @{ 'derivative $p}. -interpretation "Rderivative" 'derivative f = - (cic:/matita/demo/power_derivative/derivative.con f). +interpretation "Rderivative" 'derivative f = (derivative f). -theorem derivative_power': ∀n:nat. D[x \sup (1+n)] = (1+n)*x \sup n. +theorem derivative_power': ∀n:nat. D[X \sup (1+n)] = (1+n) · X \sup n. assume n:nat. - we proceed by induction on n to prove - (D[x \sup (1+n)] = (1+n)*x \sup n). + (*we proceed by induction on n to prove + (D[X \sup (1+n)] = (1+n) · X \sup n).*) elim n 0. case O. - the thesis becomes (D[x \sup 1] = 1*x \sup 0). - by _ + the thesis becomes (D[X \sup 1] = 1 · X \sup 0). done. case S (m:nat). by induction hypothesis we know - (D[x \sup (1+m)] = (1+m)*x \sup m) (H). + (D[X \sup (1+m)] = (1+m) · X \sup m) (H). the thesis becomes - (D[x \sup (2+m)] = (2+m)*x \sup (1+m)). + (D[X \sup (2+m)] = (2+m) · X \sup (1+m)). conclude - (D[x \sup (2+m)]) - = (D[x \sup 1 * x \sup (1+m)]) by _. - = (D[x \sup 1] * x \sup (1+m) + x * D[x \sup (1+m)]) by _. - = (x \sup (1+m) + x * (costante (1+m) * x \sup m)) by _. -clear H. - = (x \sup (1+m) + costante (1+m) * x \sup (1+m)) by _. - = (x \sup (1+m) * (costante (2 + m))) by _ + (D[X \sup (2+m)]) + = (D[X · X \sup (1+m)]). + = (D[X] · X \sup (1+m) + X · D[X \sup (1+m)]). + = (X \sup (1+m) + X · (costante (1+m) · X \sup m)). + = (X \sup (1+m) + costante (1+m) · X \sup (1+m)). + = ((2+m) · X \sup (1+m)) timeout=30 by Fmult_one_f, Fmult_commutative, + Fmult_Fplus_distr, assoc_plus, plus_n_SO, costante_sum done. qed.