author | wenzelm |
Mon, 16 Nov 1998 10:41:08 +0100 | |
changeset 5869 | b279a84ac11c |
parent 5184 | 9b8547a9496a |
child 8422 | 6c6a5410a9bd |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/ex/insort.ML |
969 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Tobias Nipkow |
969 | 4 |
Copyright 1994 TU Muenchen |
5 |
||
6 |
Correctness proof of insertion sort. |
|
7 |
*) |
|
8 |
||
5069 | 9 |
Goal "!y. mset(ins f x xs) y = mset (x#xs) y"; |
5184 | 10 |
by (induct_tac "xs" 1); |
4686 | 11 |
by (ALLGOALS Asm_simp_tac); |
2517 | 12 |
qed "mset_ins"; |
13 |
Addsimps [mset_ins]; |
|
14 |
||
5069 | 15 |
Goal "!x. mset(insort f xs) x = mset xs x"; |
5184 | 16 |
by (induct_tac "xs" 1); |
2517 | 17 |
by (ALLGOALS Asm_simp_tac); |
18 |
qed "insort_permutes"; |
|
19 |
||
5069 | 20 |
Goal "set(ins f x xs) = insert x (set xs)"; |
4686 | 21 |
by (asm_simp_tac (simpset() addsimps [set_via_mset]) 1); |
2031 | 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 | 25 |
|
2517 | 26 |
val prems = goalw InSort.thy [total_def,transf_def] |
969 | 27 |
"[| total(f); transf(f) |] ==> sorted f (ins f x xs) = sorted f xs"; |
5184 | 28 |
by (induct_tac "xs" 1); |
4686 | 29 |
by (ALLGOALS Asm_simp_tac); |
2031 | 30 |
by (cut_facts_tac prems 1); |
2517 | 31 |
by (Fast_tac 1); |
2511 | 32 |
qed "sorted_ins"; |
33 |
Addsimps [sorted_ins]; |
|
969 | 34 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
35 |
Goal "[| total(f); transf(f) |] ==> sorted f (insort f xs)"; |
5184 | 36 |
by (induct_tac "xs" 1); |
2031 | 37 |
by (ALLGOALS Asm_simp_tac); |
1750
817a34a54fb0
replaced result() by qed "sorted_insort" in last proof
berghofe
parents:
1465
diff
changeset
|
38 |
qed "sorted_insort"; |