src/HOL/ex/NatSum.ML
author paulson
Mon, 03 Jun 1996 11:41:26 +0200
changeset 1783 173ce86b4c22
parent 1465 5d7a7e439cec
child 1805 10494d0241cd
permissions -rw-r--r--
Used 2 instead of Suc(Suc 0)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1266
diff changeset
     1
(*  Title:      HOL/ex/natsum.ML
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1266
diff changeset
     3
    Author:     Tobias Nipkow
969
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.*)
1783
173ce86b4c22 Used 2 instead of Suc(Suc 0)
paulson
parents: 1465
diff changeset
    12
goal NatSum.thy "2*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