ex/qsort.thy
author convert-repo
Thu, 23 Jul 2009 14:03:20 +0000
changeset 255 435bf30c29a5
parent 48 21291189b51e
permissions -rw-r--r--
update tags

(*  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,x#xs) = qsort(le,[y:xs . ~le(x,y)]) @ \
\                            (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(x#xs) |] \
\ ==> P(xs)"
end