src/HOL/ex/NatSum.ML
changeset 8770 bfab4d4b7516
parent 8493 60c2f892b1d9
child 8780 b0c32189b2c1
--- a/src/HOL/ex/NatSum.ML	Sun Apr 23 11:41:06 2000 +0200
+++ b/src/HOL/ex/NatSum.ML	Sun Apr 23 11:41:45 2000 +0200
@@ -32,3 +32,26 @@
 by (induct_tac "n" 1);
 by Auto_tac;
 qed "sum_of_cubes";
+
+
+(** Repeating some of the previous examples using binary numerals **)
+
+(*The sum of the first n positive integers equals n(n+1)/2.*)
+Goal "#2 * sum id (Suc n) = n*Suc(n)";
+by (induct_tac "n" 1);
+by Auto_tac;
+qed "sum_of_naturals";
+
+Addsimps [add_mult_distrib, add_mult_distrib2];
+
+Goal "#6 * sum (%i. i*i) (Suc n) = n * Suc(n) * Suc(#2*n)";
+by (induct_tac "n" 1);
+by Auto_tac;
+(*12.6 secs, down to 5.9 secs, down to 4 secs*)
+qed "sum_of_squares";
+
+Goal "#4 * sum (%i. i*i*i) (Suc n) = n * n * Suc(n) * Suc(n)";
+by (induct_tac "n" 1);
+by Auto_tac;
+(*27.7 secs, down to 10.9 secs, down to 7.3 secs*)
+qed "sum_of_cubes";