Improved length = size translation.
authornipkow
Wed, 09 Jul 1997 12:57:04 +0200
changeset 3507 157be29ad5ba
parent 3506 a36e0a49d2cd
child 3508 089806e6133b
Improved length = size translation.
src/HOL/List.thy
--- a/src/HOL/List.thy	Mon Jul 07 10:49:14 1997 +0200
+++ b/src/HOL/List.thy	Wed Jul 09 12:57:04 1997 +0200
@@ -55,7 +55,7 @@
 (*Function "size" is overloaded for all datatypes.  Users may refer to the
   list version as "length".*)
 syntax   length :: 'a list => nat
-translations  "length"  =>  "size"
+translations  "length"  =>  "size:: _ list => nat"
 
 primrec hd list
   "hd([]) = arbitrary"
@@ -111,3 +111,19 @@
   "dropWhile P (x#xs) = (if P x then dropWhile P xs else xs)"
 
 end
+
+ML
+
+local
+
+(* translating size::list -> length *)
+
+fun size_tr' (Type ("fun", (Type ("list", _) :: _))) [t] =
+      Syntax.const "length" $ t
+  | size_tr'   _ _ = raise Match;
+
+in
+
+val typed_print_translation = [("size", size_tr')];
+
+end;