fun timer (f:'a->'b) a =
   let val start = Portable.Timer.startRealTimer ()
       val b = f a
       val _ = Lib.say (Portable.Time.toString
                 (Portable.Timer.checkRealTimer start)^"\n")
   in  b
   end;

val def = timer function;
new_theory"test2";

(* 0.240000
   0.230000
*)
def `(g (x,0) = 1) /\
     (g (0,x) = 2)`; 

(* 0.230000
   0.250000
*)
def `(g1 (0,x) = x) /\
     (g1 (x,0) = x)`; 

(* 0.610000
   0.690000
*)
def `(g2 ([]:'a list, a::b::x) = 1) /\
     (g2 (a::b::x,    y)       = 2) /\
     (g2 (z,          a::y)    = 3)`;	

(* g3 0.800000 
      0.930000
*)
def `(g3 (x,y,0) = 1) /\
     (g3 (x,0,y) = 2) /\
     (g3 (0,x,y) = 3)`;

(* g4 0.750000 
      0.920000
*)
def `(g4 (0,y,z) = 1) /\
     (g4 (x,0,z) = 2) /\
     (g4 (x,y,0) = 3)`;

(* g5 2.740000 
      3.010000
*)
def `(g5(0,x,y,z) = 1) /\
     (g5(w,0,y,z) = 2) /\
     (g5(w,x,0,z) = 3) /\
     (g5(w,x,y,0) = 4)`;

(* g6 9.760000 
     10.780000
*)
def `(g6 (0,w,x,y,z) = 1) /\
     (g6 (v,0,x,y,z) = 2) /\
     (g6 (v,w,0,y,z) = 3) /\
     (g6 (v,w,x,0,z) = 4) /\
     (g6 (v,w,x,y,0) = 5)`;

(* g7 0.840000 
      0.900000
*)
def `(g7 [x; 0] = x) /\
     (g7 [SUC v] = 1) /\
     (g7 z = 2)`;

(* g8 1.080000 
      1.180000
*)
def `(g8 (h1::h2::h3::h4::h5::h6) = [h1;h2;h3;h4;h5]::[h6]) /\ 
     (g8 x = [x:'a list])`;

(* Normal *)
def `(g9 (SUC(SUC x)) = 1) /\
     (g9 (SUC x) = 2) /\
     (g9 0 = 3)`;

(*---------------------------------------------------------------------------
 * Unaccessible patterns
 *---------------------------------------------------------------------------*)
def `(h (x:num) = 1) /\
     (h x = 2)`;

def `(h1 (x:num,0) = 1) /\
     (h1 (x,SUC y) = 2) /\
     (h1 (x,y) = 3) /\
     (h1 (x,y) = 3)`;

def `(h2 (x,0) = 1) /\
     (h2 (0,x) = 2) /\
     (h2 (0,0) = 3) /\ 
     (h2 (x,y) = 4)`; 
