src/HOL/ex/InSort.ML
author paulson
Thu, 21 Aug 1997 12:53:23 +0200
changeset 3647 a64c8fbcd98f
parent 3465 e85c24717cad
child 3919 c036caebfc75
permissions -rw-r--r--
Renamed theorems of the form set_of_list_XXX to set_XXX
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
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
     9
goal thy "!y. mset(ins f x xs) y = mset (x#xs) y";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    10
by (list.induct_tac "xs" 1);
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    11
by (Asm_simp_tac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    12
by (asm_simp_tac (!simpset setloop (split_tac [expand_if])) 1);
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    13
qed "mset_ins";
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    14
Addsimps [mset_ins];
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    15
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    16
goal thy "!x. mset(insort f xs) x = mset xs x";
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    17
by (list.induct_tac "xs" 1);
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    18
by (ALLGOALS Asm_simp_tac);
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    19
qed "insort_permutes";
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    20
3465
e85c24717cad set_of_list -> set
nipkow
parents: 2526
diff changeset
    21
goal thy "set(ins f x xs) = insert x (set xs)";
3647
a64c8fbcd98f Renamed theorems of the form set_of_list_XXX to set_XXX
paulson
parents: 3465
diff changeset
    22
by (asm_simp_tac (!simpset addsimps [set_via_mset]
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    23
                           setloop (split_tac [expand_if])) 1);
2031
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    24
by (Fast_tac 1);
3647
a64c8fbcd98f Renamed theorems of the form set_of_list_XXX to set_XXX
paulson
parents: 3465
diff changeset
    25
qed "set_ins";
a64c8fbcd98f Renamed theorems of the form set_of_list_XXX to set_XXX
paulson
parents: 3465
diff changeset
    26
Addsimps [set_ins];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    28
val prems = goalw InSort.thy [total_def,transf_def]
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    29
  "[| total(f); transf(f) |] ==>  sorted f (ins f x xs) = sorted f xs";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    30
by (list.induct_tac "xs" 1);
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    31
by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    32
by (cut_facts_tac prems 1);
2517
2af078382853 Modified some defs and shortened proofs.
nipkow
parents: 2511
diff changeset
    33
by (Fast_tac 1);
2511
282e9a9eae9d Got rid of Alls in favour of !x:set_of_list
nipkow
parents: 2031
diff changeset
    34
qed "sorted_ins";
282e9a9eae9d Got rid of Alls in favour of !x:set_of_list
nipkow
parents: 2031
diff changeset
    35
Addsimps [sorted_ins];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    36
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    37
goal InSort.thy "!!f. [| total(f); transf(f) |] ==>  sorted f (insort f xs)";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    38
by (list.induct_tac "xs" 1);
03a843f0f447 Ran expandshort
paulson
parents: 1820
diff changeset
    39
by (ALLGOALS Asm_simp_tac);
1750
817a34a54fb0 replaced result() by qed "sorted_insort" in last proof
berghofe
parents: 1465
diff changeset
    40
qed "sorted_insort";