| author | wenzelm | 
| Wed, 16 Apr 1997 18:53:36 +0200 | |
| changeset 2967 | 89db5eedecab | 
| parent 2526 | 43650141d67d | 
| child 3465 | e85c24717cad | 
| permissions | -rw-r--r-- | 
| 1465 | 1 | (* Title: HOL/ex/qsort.ML | 
| 969 | 2 | ID: $Id$ | 
| 1465 | 3 | Author: Tobias Nipkow | 
| 969 | 4 | Copyright 1994 TU Muenchen | 
| 5 | ||
| 6 | Two verifications of Quicksort | |
| 7 | *) | |
| 8 | ||
| 2526 | 9 | Addsimps [ball_Un]; | 
| 2511 | 10 | |
| 11 | (* Towards a proof of qsort_ind | |
| 12 | ||
| 13 | A short proof of Konrad's wf_minimal in WF1.ML: | |
| 14 | ||
| 15 | val [p1] = goalw WF.thy [wf_def] | |
| 16 | "wf(R) ==> (!Q. (? x. Q x) --> (? min. Q min & (!b. (b,min):R --> (~ Q b))))"; | |
| 17 | by (rtac allI 1); | |
| 18 | by(cut_inst_tac[("x","%u.~Q u")](p1 RS spec) 1);
 | |
| 19 | by (fast_tac HOL_cs 1); | |
| 20 | val wf_minimal = result(); | |
| 21 | ||
| 22 | *) | |
| 23 | ||
| 24 | ||
| 1266 | 25 | Addsimps ([Qsort.qsort_Nil,Qsort.qsort_Cons]@conj_comms); | 
| 969 | 26 | |
| 27 | goal Qsort.thy "!x. mset (qsort le xs) x = mset xs x"; | |
| 2031 | 28 | by (res_inst_tac[("xs","xs"),("p","le")]Qsort.qsort_ind 1);
 | 
| 29 | by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if])))); | |
| 2511 | 30 | qed "qsort_permutes"; | 
| 969 | 31 | |
| 2511 | 32 | goal Qsort.thy "set_of_list(qsort le xs) = set_of_list xs"; | 
| 33 | by(simp_tac (!simpset addsimps [set_of_list_via_mset,qsort_permutes]) 1); | |
| 34 | qed "set_of_list_qsort"; | |
| 35 | Addsimps [set_of_list_qsort]; | |
| 969 | 36 | |
| 2511 | 37 | goal List.thy | 
| 38 | "(!x:set_of_list[x:xs.P(x)].Q(x)) = (!x:set_of_list xs. P(x)-->Q(x))"; | |
| 39 | by (list.induct_tac "xs" 1); | |
| 40 | by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if])))); | |
| 41 | qed"Ball_set_of_list_filter"; | |
| 42 | Addsimps [Ball_set_of_list_filter]; | |
| 969 | 43 | |
| 44 | goal Qsort.thy | |
| 45 | "sorted le (xs@ys) = (sorted le xs & sorted le ys & \ | |
| 2511 | 46 | \ (!x:set_of_list xs. !y:set_of_list ys. le x y))"; | 
| 2031 | 47 | by (list.induct_tac "xs" 1); | 
| 2511 | 48 | by (ALLGOALS Asm_simp_tac); | 
| 49 | qed "sorted_append"; | |
| 50 | Addsimps [sorted_append]; | |
| 1673 
d22110ddd0af
repaired critical proofs depending on the order inside non-confluent SimpSets
 oheimb parents: 
1465diff
changeset | 51 | |
| 969 | 52 | goal Qsort.thy | 
| 53 | "!!le. [| total(le); transf(le) |] ==> sorted le (qsort le xs)"; | |
| 2031 | 54 | by (res_inst_tac[("xs","xs"),("p","le")]Qsort.qsort_ind 1);
 | 
| 2511 | 55 | by (ALLGOALS Asm_simp_tac); | 
| 2031 | 56 | by (rewrite_goals_tac [Sorting.total_def,Sorting.transf_def]); | 
| 57 | by (Fast_tac 1); | |
| 2511 | 58 | qed "sorted_qsort"; |