]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/library/demo/power_derivative.ma
changed auto_tac params type and all derivate tactics like applyS and
[helm.git] / helm / software / matita / library / demo / power_derivative.ma
index ce288b731ad998b959d2c71b8cc74455b79daff9..4f1b44000889a1df1b765d98a29977b8a3b2a432 100644 (file)
@@ -41,6 +41,11 @@ interpretation "None" 'one =
 
 interpretation "Rplus" 'plus x y =
  (cic:/matita/demo/power_derivative/Rplus.con x y).
+
+notation "hvbox(a break \middot b)" 
+  left associative with precedence 55
+for @{ 'times $a $b }.
+
 interpretation "Rmult" 'times x y =
  (cic:/matita/demo/power_derivative/Rmult.con x y).
 
@@ -48,7 +53,7 @@ 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).
@@ -69,7 +74,7 @@ interpretation "Ntwo" 'two =
 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 =
@@ -110,22 +115,22 @@ coercion cic:/matita/demo/power_derivative/costante.con 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 +139,7 @@ lemma Fmult_commutative: symmetric ? Fmult.
  unfold Fmult;
  apply f_eq_extensional;
  intros;
- auto.
+ autobatch.
 qed.
 
 lemma Fmult_associative: associative ? Fmult.
@@ -144,7 +149,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 +160,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 +173,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 +196,7 @@ lemma costante_sum:
  intros;
  elim n;
   [ simplify;
-    auto
+    autobatch
   | simplify;
     clear x;
     clear H;
@@ -200,19 +205,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
         ]
      ]
    ].
@@ -240,28 +245,29 @@ interpretation "Rmonomio" '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_mult: ∀f,g:R→R. D[f·g] = D[f]·g + f·D[g].
 
 alias symbol "times" = "Fmult".
 
-theorem derivative_power: ∀n:nat. D[x \sup n] = n*x \sup (pred n).
+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)).
+   the thesis becomes (D[x \sup 0] = 0·x \sup (pred 0)).
    by _
   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).
+   (m · (x \sup (1+ pred m)) = m · x \sup m) (Ppred).
    by _ 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).
@@ -271,16 +277,16 @@ theorem derivative_power: ∀n:nat. D[x \sup n] = n*x \sup (pred n).
       suppose (0=m) (m_zero). by _ 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 · x \sup m]).
+   = (D[x] · x \sup m + x · D[x \sup m]).
+   = (x \sup m + x · (m · x \sup (pred m))).
+   = (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.
 
+(*
 notation "hvbox(\frac 'd' ('d' ident i) break p)"
   right associative with precedence 90
 for @{ 'derivative ${default
@@ -289,27 +295,103 @@ for @{ 'derivative ${default
 
 interpretation "Rderivative" 'derivative \eta.f =
  (cic:/matita/demo/power_derivative/derivative.con f).
+*)
 
-theorem derivative_power': ∀n:nat. D[x \sup (1+n)] = (1+n)*x \sup n.
+notation "hvbox(\frac 'd' ('d' 'x') break p)"
+  right associative with precedence 90
+for @{ 'derivative $p}.
+
+interpretation "Rderivative" 'derivative f =
+ (cic:/matita/demo/power_derivative/derivative.con f).
+
+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).
+   the thesis becomes (D[x \sup 1] = 1 · x \sup 0).
    by _
   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 _
-  done.
+   = (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)).
+
+
+
+  conclude (x \sup (1+m) + costante (1+m) · x \sup (1+m))
+  = (costante 1 · x \sup (1+m) + costante (1+m) ·(x) \sup (1+m)) proof.
+   by (Fmult_one_f ((x)\sup(1+m)))
+   we proved (costante 1·(x)\sup(1+m)=(x)\sup(1+m)) (previous).
+   by (eq_OF_eq ? ? (λfoo:(R→R).foo+costante (1+m)·(x)\sup(1+m)) (costante 1
+                                                                                                                                                                                                                                       ·(x)\sup(1
+                                                                                                                                                                                                                                                    +m)) ((x)\sup(1
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             +m)) previous)
+   done.
+  = ((x)\sup(1+m)·costante 1+costante (1+m)·(x)\sup(1+m)) proof.
+   by (Fmult_commutative (costante 1) ((x)\sup(1+m)))
+   we proved (costante 1·(x)\sup(1+m)=(x)\sup(1+m)·costante 1) (previous).
+   by (eq_f ? ? (λfoo:(R→R).foo+costante (1+m)·(x)\sup(1+m)) (costante 1
+                                                                                                                                                                                                       ·(x)\sup(1+m)) ((x)\sup(1
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         +m)
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ·costante
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1) previous)
+   done.
+  = ((x)\sup(1+m)·costante 1+(x)\sup(1+m)·costante (1+m)) proof.
+   by (Fmult_commutative ((x)\sup(1+m)) (costante (1+m)))
+   we proved ((x)\sup(1+m)·costante (1+m)=costante (1+m)·(x)\sup(1+m))
+    
+   (previous)
+   .
+   by (eq_OF_eq ? ? (λfoo:(R→R).(x)\sup(1+m)·costante 1+foo) ((x)\sup(1+m)
+                                                                                                                                                                                                                               ·costante
+                                                                                                                                                                                                                                 (1+m)) (costante
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (1
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         +m)
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ·(x)\sup(1
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     +m)) previous)
+   done.
+  = ((x)\sup(1+m)·(costante 1+costante (1+m))) proof.
+   by (Fmult_Fplus_distr ((x)\sup(1+m)) (costante 1) (costante (1+m)))
+   we proved
+   ((x)\sup(1+m)·(costante 1+costante (1+m))
+    =(x)\sup(1+m)·costante 1+(x)\sup(1+m)·costante (1+m))
+    
+   (previous)
+   .
+   by (sym_eq ? ((x)\sup(1+m)·(costante 1+costante (1+m))) ((x)\sup(1+m)
+                                                                                                                                                                            ·costante 1
+                                                                                                                                                                            +(x)\sup(1+m)
+                                                                                                                                                                             ·costante (1+m)) previous)
+   done.
+  = ((costante 1+costante (1+m))·(x)\sup(1+m)) 
+  exact (Fmult_commutative ((x)\sup(1+m)) (costante 1+costante (1+m))).
+  = (costante (1+(1+m))·(x)\sup(1+m)) proof.
+   by (costante_sum 1 (1+m))
+   we proved (costante 1+costante (1+m)=costante (1+(1+m))) (previous).
+   by (eq_f ? ? (λfoo:(R→R).foo·(x)\sup(1+m)) (costante 1+costante (1+m)) (costante
+                                                                                                                                                                                                                                                                                                                              (1
+                                                                                                                                                                                                                                                                                                                               +(1
+                                                                                                                                                                                                                                                                                                                                 +m))) previous)
+   done.
+  = (costante (1+1+m)·(x)\sup(1+m)) proof.
+   by (assoc_plus 1 1 m)
+   we proved (1+1+m=1+(1+m)) (previous).
+   by (eq_OF_eq ? ? (λfoo:nat.costante foo·(x)\sup(1+m)) ? ? previous)
+   done.
+  = (costante (2+m)·(x)\sup(1+m)) proof done.
+   by (plus_n_SO 1)
+   we proved (2=1+1) (previous).
+   by (eq_OF_eq ? ? (λfoo:nat.costante (foo+m)·(x)\sup(1+m)) ? ? previous)
+   done.
+  
+(* end auto($Revision: 8206 $) proof: TIME=0.06 SIZE=100 DEPTH=100 *)  done.
 qed.