src/HOL/ex/NatSum.ML
author paulson
Thu, 18 Jan 1996 10:38:29 +0100
changeset 1444 23ceb1dc9755
parent 1266 3ae9fe3c0f68
child 1465 5d7a7e439cec
permissions -rw-r--r--
trivial updates
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
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
     9
Addsimps ([NatSum.sum_0,NatSum.sum_Suc] @ add_ac);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
(*The sum of the first n positive integers equals n(n+1)/2.*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
goal NatSum.thy "Suc(Suc(0))*sum (%i.i) (Suc n) = n*Suc(n)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    13
by (Simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
by (nat_ind_tac "n" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    15
by (Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    16
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    17
qed "sum_of_naturals";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    18
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    19
goal NatSum.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    20
  "Suc(Suc(Suc(Suc(Suc(Suc(0))))))*sum (%i.i*i) (Suc n) = \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    21
\  n*Suc(n)*Suc(Suc(Suc(0))*n)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    22
by (Simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    23
by (nat_ind_tac "n" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    24
by (Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    25
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    26
qed "sum_of_squares";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    28
goal NatSum.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    29
  "Suc(Suc(Suc(Suc(0))))*sum (%i.i*i*i) (Suc n) = n*n*Suc(n)*Suc(n)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    30
by (Simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    31
by (nat_ind_tac "n" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    32
by (Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    33
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    34
qed "sum_of_cubes";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    35
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    36
(*The sum of the first n odd numbers equals n squared.*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    37
goal NatSum.thy "sum (%i.Suc(i+i)) n = n*n";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    38
by (nat_ind_tac "n" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    39
by (Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    40
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    41
qed "sum_of_odds";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    42