src/HOL/ex/NatSum.ML
author wenzelm
Mon, 29 Nov 1999 15:52:49 +0100
changeset 8039 a901bafe4578
parent 5206 a3f26b19cd7e
child 8356 14d89313c66c
permissions -rw-r--r--
Goal: tuned pris;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1805
10494d0241cd Explicitly included add_mult_distrib & add_mult_distrib2
paulson
parents: 1783
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
3269
eca2a3634acd Function "sum" now defined using primrec
paulson
parents: 1805
diff changeset
     6
Summing natural numbers, squares and cubes.  Could be continued...
eca2a3634acd Function "sum" now defined using primrec
paulson
parents: 1805
diff changeset
     7
Demonstrates permutative rewriting.
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
4558
31becfd8d329 Delsimprocs nat_cancel;
wenzelm
parents: 4246
diff changeset
    10
Delsimprocs nat_cancel;
3269
eca2a3634acd Function "sum" now defined using primrec
paulson
parents: 1805
diff changeset
    11
Addsimps add_ac;
eca2a3634acd Function "sum" now defined using primrec
paulson
parents: 1805
diff changeset
    12
Addsimps [add_mult_distrib, add_mult_distrib2];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
(*The sum of the first n positive integers equals n(n+1)/2.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4558
diff changeset
    15
Goal "2*sum (%i. i) (Suc n) = n*Suc(n)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    16
by (Simp_tac 1);
4246
c539e702e1d2 Now uses induct_tac
paulson
parents: 3842
diff changeset
    17
by (induct_tac "n" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    18
by (Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    19
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    20
qed "sum_of_naturals";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    21
5206
paulson
parents: 5069
diff changeset
    22
Goal "Suc(Suc(Suc(Suc 2)))*sum (%i. i*i) (Suc n) = n*Suc(n)*Suc(2*n)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    23
by (Simp_tac 1);
4246
c539e702e1d2 Now uses induct_tac
paulson
parents: 3842
diff changeset
    24
by (induct_tac "n" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    25
by (Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 969
diff changeset
    26
by (Asm_simp_tac 1);
969
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
5206
paulson
parents: 5069
diff changeset
    29
Goal "Suc(Suc 2)*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);
4246
c539e702e1d2 Now uses induct_tac
paulson
parents: 3842
diff changeset
    31
by (induct_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.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4558
diff changeset
    37
Goal "sum (%i. Suc(i+i)) n = n*n";
4246
c539e702e1d2 Now uses induct_tac
paulson
parents: 3842
diff changeset
    38
by (induct_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