src/HOL/ex/NatSum.ML
author clasohm
Wed, 21 Jun 1995 15:47:10 +0200
changeset 1151 c820b3cc3df0
parent 969 b051e2fc2e34
child 1266 3ae9fe3c0f68
permissions -rw-r--r--
removed \...\ inside strings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/ex/natsum.ML
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Tobias Nipkow
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1994 TU Muenchen
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     6
Summing natural numbers, squares and cubes. Could be continued...
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
val natsum_ss = arith_ss addsimps
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
  ([NatSum.sum_0,NatSum.sum_Suc] @ add_ac);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
(*The sum of the first n positive integers equals n(n+1)/2.*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
goal NatSum.thy "Suc(Suc(0))*sum (%i.i) (Suc n) = n*Suc(n)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    15
by (nat_ind_tac "n" 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    16
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    17
by (asm_simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    18
qed "sum_of_naturals";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    19
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    20
goal NatSum.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    21
  "Suc(Suc(Suc(Suc(Suc(Suc(0))))))*sum (%i.i*i) (Suc n) = \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    22
\  n*Suc(n)*Suc(Suc(Suc(0))*n)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    23
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    24
by (nat_ind_tac "n" 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    25
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    26
by (asm_simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
qed "sum_of_squares";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    28
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    29
goal NatSum.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    30
  "Suc(Suc(Suc(Suc(0))))*sum (%i.i*i*i) (Suc n) = n*n*Suc(n)*Suc(n)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    31
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    32
by (nat_ind_tac "n" 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    33
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    34
by (asm_simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    35
qed "sum_of_cubes";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    36
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    37
(*The sum of the first n odd numbers equals n squared.*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    38
goal NatSum.thy "sum (%i.Suc(i+i)) n = n*n";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    39
by (nat_ind_tac "n" 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    40
by (simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    41
by (asm_simp_tac natsum_ss 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    42
qed "sum_of_odds";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    43