ex/Qsort.thy
author nipkow
Wed, 23 Feb 1994 10:05:35 +0100
changeset 46 a73f8a7784bd
parent 37 65a546c2b8ed
child 48 21291189b51e
permissions -rw-r--r--
some more sorting algorithms

(*  Title: 	HOL/ex/qsort.thy
    ID:         $Id$
    Author: 	Tobias Nipkow
    Copyright   1994 TU Muenchen

Quicksort
*)

Qsort = Sorting +
consts
  qsort  :: "[['a,'a] => bool, 'a list] => 'a list"

rules

qsort_Nil  "qsort(le,[]) = []"
qsort_Cons "qsort(le,Cons(x,xs)) = qsort(le,[y:xs . ~le(x,y)]) @ \
\                                  Cons(x, qsort(le,[y:xs . le(x,y)]))"

(* computational induction.
   The dependence of p on x but not xs is intentional.
*)
qsort_ind
 "[| P([]); \
\    !!x xs. [| P([y:xs . ~p(x,y)]); P([y:xs . p(x,y)]) |] ==> \
\            P(Cons(x,xs)) |] \
\ ==> P(xs)"
end