src/HOL/ex/InSort.ML
author nipkow
Fri, 24 Nov 2000 16:49:27 +0100
changeset 10519 ade64af4c57c
parent 8422 6c6a5410a9bd
permissions -rw-r--r--
hide many names from Datatype_Universe.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1266
diff changeset
     1
(*  Title:      HOL/ex/insort.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
Correctness proof of insertion sort.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
     9
Goal "!y. multiset(ins le x xs) y = multiset (x#xs) y";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5143
diff changeset
    10
by (induct_tac "xs" 1);
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    11
by Auto_tac;
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    12
qed_spec_mp "multiset_ins";
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    13
Addsimps [multiset_ins];
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    14
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    15
Goal "!x. multiset(insort le xs) x = multiset xs x";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5143
diff changeset
    16
by (induct_tac "xs" 1);
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    17
by Auto_tac;
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    18
qed_spec_mp "insort_permutes";
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    19
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    20
Goal "set(ins le x xs) = insert x (set xs)";
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    21
by (asm_simp_tac (simpset() addsimps [set_via_multiset]) 1);
2031
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    22
by (Fast_tac 1);
3647
a64c8fbcd98f Renamed theorems of the form set_of_list_XXX to set_XXX
paulson
parents: 3465
diff changeset
    23
qed "set_ins";
a64c8fbcd98f Renamed theorems of the form set_of_list_XXX to set_XXX
paulson
parents: 3465
diff changeset
    24
Addsimps [set_ins];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    25
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    26
Goal "total(le) --> transf(le) --> sorted le (ins le x xs) = sorted le xs";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5143
diff changeset
    27
by (induct_tac "xs" 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4089
diff changeset
    28
by (ALLGOALS Asm_simp_tac);
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    29
by (rewrite_goals_tac [Sorting.total_def, Sorting.transf_def]);
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    30
by (Blast_tac 1);
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    31
qed_spec_mp "sorted_ins";
2511
282e9a9eae9d Got rid of Alls in favour of !x:set_of_list
nipkow
parents: 2031
diff changeset
    32
Addsimps [sorted_ins];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    33
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    34
Goal "[| total(le); transf(le) |] ==>  sorted le (insort le xs)";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5143
diff changeset
    35
by (induct_tac "xs" 1);
8422
6c6a5410a9bd renamed "f" to "le" and "mset" to "multiset"
paulson
parents: 5184
diff changeset
    36
by Auto_tac;
1750
817a34a54fb0 replaced result() by qed "sorted_insort" in last proof
berghofe
parents: 1465
diff changeset
    37
qed "sorted_insort";