ex/insort.thy
author lcp
Thu, 13 Oct 1994 09:39:15 +0100
changeset 153 c0ff8f1ebc16
parent 48 21291189b51e
permissions -rw-r--r--
HOL/HOL.ML/selectI2: new rule for descriptions

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

Insertion sort
*)

InSort  =  Sorting +

consts
  ins :: "[['a,'a]=>bool, 'a, 'a list] => 'a list"
  insort :: "[['a,'a]=>bool, 'a list] => 'a list"

rules
  ins_Nil  "ins(f,x,[]) = [x]"
  ins_Cons "ins(f,x,y#ys) =   \
\	       if(f(x,y), x#y#ys, y# ins(f,x,ys))"

  insort_Nil  "insort(f,[]) = []"
  insort_Cons "insort(f,x#xs) = ins(f,x,insort(f,xs))"
end