equal
deleted
inserted
replaced
5 |
5 |
6 Correctness proof of insertion sort. |
6 Correctness proof of insertion sort. |
7 *) |
7 *) |
8 |
8 |
9 Goal "!y. mset(ins f x xs) y = mset (x#xs) y"; |
9 Goal "!y. mset(ins f x xs) y = mset (x#xs) y"; |
10 by (list.induct_tac "xs" 1); |
10 by (induct_tac "xs" 1); |
11 by (ALLGOALS Asm_simp_tac); |
11 by (ALLGOALS Asm_simp_tac); |
12 qed "mset_ins"; |
12 qed "mset_ins"; |
13 Addsimps [mset_ins]; |
13 Addsimps [mset_ins]; |
14 |
14 |
15 Goal "!x. mset(insort f xs) x = mset xs x"; |
15 Goal "!x. mset(insort f xs) x = mset xs x"; |
16 by (list.induct_tac "xs" 1); |
16 by (induct_tac "xs" 1); |
17 by (ALLGOALS Asm_simp_tac); |
17 by (ALLGOALS Asm_simp_tac); |
18 qed "insort_permutes"; |
18 qed "insort_permutes"; |
19 |
19 |
20 Goal "set(ins f x xs) = insert x (set xs)"; |
20 Goal "set(ins f x xs) = insert x (set xs)"; |
21 by (asm_simp_tac (simpset() addsimps [set_via_mset]) 1); |
21 by (asm_simp_tac (simpset() addsimps [set_via_mset]) 1); |
23 qed "set_ins"; |
23 qed "set_ins"; |
24 Addsimps [set_ins]; |
24 Addsimps [set_ins]; |
25 |
25 |
26 val prems = goalw InSort.thy [total_def,transf_def] |
26 val prems = goalw InSort.thy [total_def,transf_def] |
27 "[| total(f); transf(f) |] ==> sorted f (ins f x xs) = sorted f xs"; |
27 "[| total(f); transf(f) |] ==> sorted f (ins f x xs) = sorted f xs"; |
28 by (list.induct_tac "xs" 1); |
28 by (induct_tac "xs" 1); |
29 by (ALLGOALS Asm_simp_tac); |
29 by (ALLGOALS Asm_simp_tac); |
30 by (cut_facts_tac prems 1); |
30 by (cut_facts_tac prems 1); |
31 by (Fast_tac 1); |
31 by (Fast_tac 1); |
32 qed "sorted_ins"; |
32 qed "sorted_ins"; |
33 Addsimps [sorted_ins]; |
33 Addsimps [sorted_ins]; |
34 |
34 |
35 Goal "[| total(f); transf(f) |] ==> sorted f (insort f xs)"; |
35 Goal "[| total(f); transf(f) |] ==> sorted f (insort f xs)"; |
36 by (list.induct_tac "xs" 1); |
36 by (induct_tac "xs" 1); |
37 by (ALLGOALS Asm_simp_tac); |
37 by (ALLGOALS Asm_simp_tac); |
38 qed "sorted_insort"; |
38 qed "sorted_insort"; |