src/HOL/Fun.thy
author wenzelm
Fri Mar 28 19:43:54 2008 +0100 (2008-03-28)
changeset 26462 dac4e2bce00d
parent 26357 19b153ebda0b
child 26588 d83271bfaba5
permissions -rw-r--r--
avoid rebinding of existing facts;
     1 (*  Title:      HOL/Fun.thy
     2     ID:         $Id$
     3     Author:     Tobias Nipkow, Cambridge University Computer Laboratory
     4     Copyright   1994  University of Cambridge
     5 *)
     6 
     7 header {* Notions about functions *}
     8 
     9 theory Fun
    10 imports Set
    11 begin
    12 
    13 text{*As a simplification rule, it replaces all function equalities by
    14   first-order equalities.*}
    15 lemma expand_fun_eq: "f = g \<longleftrightarrow> (\<forall>x. f x = g x)"
    16 apply (rule iffI)
    17 apply (simp (no_asm_simp))
    18 apply (rule ext)
    19 apply (simp (no_asm_simp))
    20 done
    21 
    22 lemma apply_inverse:
    23   "f x = u \<Longrightarrow> (\<And>x. P x \<Longrightarrow> g (f x) = x) \<Longrightarrow> P x \<Longrightarrow> x = g u"
    24   by auto
    25 
    26 
    27 subsection {* The Identity Function @{text id} *}
    28 
    29 definition
    30   id :: "'a \<Rightarrow> 'a"
    31 where
    32   "id = (\<lambda>x. x)"
    33 
    34 lemma id_apply [simp]: "id x = x"
    35   by (simp add: id_def)
    36 
    37 lemma image_ident [simp]: "(%x. x) ` Y = Y"
    38 by blast
    39 
    40 lemma image_id [simp]: "id ` Y = Y"
    41 by (simp add: id_def)
    42 
    43 lemma vimage_ident [simp]: "(%x. x) -` Y = Y"
    44 by blast
    45 
    46 lemma vimage_id [simp]: "id -` A = A"
    47 by (simp add: id_def)
    48 
    49 
    50 subsection {* The Composition Operator @{text "f \<circ> g"} *}
    51 
    52 definition
    53   comp :: "('b \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'c" (infixl "o" 55)
    54 where
    55   "f o g = (\<lambda>x. f (g x))"
    56 
    57 notation (xsymbols)
    58   comp  (infixl "\<circ>" 55)
    59 
    60 notation (HTML output)
    61   comp  (infixl "\<circ>" 55)
    62 
    63 text{*compatibility*}
    64 lemmas o_def = comp_def
    65 
    66 lemma o_apply [simp]: "(f o g) x = f (g x)"
    67 by (simp add: comp_def)
    68 
    69 lemma o_assoc: "f o (g o h) = f o g o h"
    70 by (simp add: comp_def)
    71 
    72 lemma id_o [simp]: "id o g = g"
    73 by (simp add: comp_def)
    74 
    75 lemma o_id [simp]: "f o id = f"
    76 by (simp add: comp_def)
    77 
    78 lemma image_compose: "(f o g) ` r = f`(g`r)"
    79 by (simp add: comp_def, blast)
    80 
    81 lemma UN_o: "UNION A (g o f) = UNION (f`A) g"
    82 by (unfold comp_def, blast)
    83 
    84 
    85 subsection {* The Forward Composition Operator @{text "f \<circ>> g"} *}
    86 
    87 definition
    88   fcomp :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'c" (infixl "o>" 60)
    89 where
    90   "f o> g = (\<lambda>x. g (f x))"
    91 
    92 notation (xsymbols)
    93   fcomp  (infixl "\<circ>>" 60)
    94 
    95 notation (HTML output)
    96   fcomp  (infixl "\<circ>>" 60)
    97 
    98 lemma fcomp_apply:  "(f o> g) x = g (f x)"
    99   by (simp add: fcomp_def)
   100 
   101 lemma fcomp_assoc: "(f o> g) o> h = f o> (g o> h)"
   102   by (simp add: fcomp_def)
   103 
   104 lemma id_fcomp [simp]: "id o> g = g"
   105   by (simp add: fcomp_def)
   106 
   107 lemma fcomp_id [simp]: "f o> id = f"
   108   by (simp add: fcomp_def)
   109 
   110 
   111 subsection {* Injectivity and Surjectivity *}
   112 
   113 constdefs
   114   inj_on :: "['a => 'b, 'a set] => bool"  -- "injective"
   115   "inj_on f A == ! x:A. ! y:A. f(x)=f(y) --> x=y"
   116 
   117 text{*A common special case: functions injective over the entire domain type.*}
   118 
   119 abbreviation
   120   "inj f == inj_on f UNIV"
   121 
   122 definition
   123   bij_betw :: "('a => 'b) => 'a set => 'b set => bool" where -- "bijective"
   124   "bij_betw f A B \<longleftrightarrow> inj_on f A & f ` A = B"
   125 
   126 constdefs
   127   surj :: "('a => 'b) => bool"                   (*surjective*)
   128   "surj f == ! y. ? x. y=f(x)"
   129 
   130   bij :: "('a => 'b) => bool"                    (*bijective*)
   131   "bij f == inj f & surj f"
   132 
   133 lemma injI:
   134   assumes "\<And>x y. f x = f y \<Longrightarrow> x = y"
   135   shows "inj f"
   136   using assms unfolding inj_on_def by auto
   137 
   138 text{*For Proofs in @{text "Tools/datatype_rep_proofs"}*}
   139 lemma datatype_injI:
   140     "(!! x. ALL y. f(x) = f(y) --> x=y) ==> inj(f)"
   141 by (simp add: inj_on_def)
   142 
   143 theorem range_ex1_eq: "inj f \<Longrightarrow> b : range f = (EX! x. b = f x)"
   144   by (unfold inj_on_def, blast)
   145 
   146 lemma injD: "[| inj(f); f(x) = f(y) |] ==> x=y"
   147 by (simp add: inj_on_def)
   148 
   149 (*Useful with the simplifier*)
   150 lemma inj_eq: "inj(f) ==> (f(x) = f(y)) = (x=y)"
   151 by (force simp add: inj_on_def)
   152 
   153 lemma inj_on_id[simp]: "inj_on id A"
   154   by (simp add: inj_on_def) 
   155 
   156 lemma inj_on_id2[simp]: "inj_on (%x. x) A"
   157 by (simp add: inj_on_def) 
   158 
   159 lemma surj_id[simp]: "surj id"
   160 by (simp add: surj_def) 
   161 
   162 lemma bij_id[simp]: "bij id"
   163 by (simp add: bij_def inj_on_id surj_id) 
   164 
   165 lemma inj_onI:
   166     "(!! x y. [|  x:A;  y:A;  f(x) = f(y) |] ==> x=y) ==> inj_on f A"
   167 by (simp add: inj_on_def)
   168 
   169 lemma inj_on_inverseI: "(!!x. x:A ==> g(f(x)) = x) ==> inj_on f A"
   170 by (auto dest:  arg_cong [of concl: g] simp add: inj_on_def)
   171 
   172 lemma inj_onD: "[| inj_on f A;  f(x)=f(y);  x:A;  y:A |] ==> x=y"
   173 by (unfold inj_on_def, blast)
   174 
   175 lemma inj_on_iff: "[| inj_on f A;  x:A;  y:A |] ==> (f(x)=f(y)) = (x=y)"
   176 by (blast dest!: inj_onD)
   177 
   178 lemma comp_inj_on:
   179      "[| inj_on f A;  inj_on g (f`A) |] ==> inj_on (g o f) A"
   180 by (simp add: comp_def inj_on_def)
   181 
   182 lemma inj_on_imageI: "inj_on (g o f) A \<Longrightarrow> inj_on g (f ` A)"
   183 apply(simp add:inj_on_def image_def)
   184 apply blast
   185 done
   186 
   187 lemma inj_on_image_iff: "\<lbrakk> ALL x:A. ALL y:A. (g(f x) = g(f y)) = (g x = g y);
   188   inj_on f A \<rbrakk> \<Longrightarrow> inj_on g (f ` A) = inj_on g A"
   189 apply(unfold inj_on_def)
   190 apply blast
   191 done
   192 
   193 lemma inj_on_contraD: "[| inj_on f A;  ~x=y;  x:A;  y:A |] ==> ~ f(x)=f(y)"
   194 by (unfold inj_on_def, blast)
   195 
   196 lemma inj_singleton: "inj (%s. {s})"
   197 by (simp add: inj_on_def)
   198 
   199 lemma inj_on_empty[iff]: "inj_on f {}"
   200 by(simp add: inj_on_def)
   201 
   202 lemma subset_inj_on: "[| inj_on f B; A <= B |] ==> inj_on f A"
   203 by (unfold inj_on_def, blast)
   204 
   205 lemma inj_on_Un:
   206  "inj_on f (A Un B) =
   207   (inj_on f A & inj_on f B & f`(A-B) Int f`(B-A) = {})"
   208 apply(unfold inj_on_def)
   209 apply (blast intro:sym)
   210 done
   211 
   212 lemma inj_on_insert[iff]:
   213   "inj_on f (insert a A) = (inj_on f A & f a ~: f`(A-{a}))"
   214 apply(unfold inj_on_def)
   215 apply (blast intro:sym)
   216 done
   217 
   218 lemma inj_on_diff: "inj_on f A ==> inj_on f (A-B)"
   219 apply(unfold inj_on_def)
   220 apply (blast)
   221 done
   222 
   223 lemma surjI: "(!! x. g(f x) = x) ==> surj g"
   224 apply (simp add: surj_def)
   225 apply (blast intro: sym)
   226 done
   227 
   228 lemma surj_range: "surj f ==> range f = UNIV"
   229 by (auto simp add: surj_def)
   230 
   231 lemma surjD: "surj f ==> EX x. y = f x"
   232 by (simp add: surj_def)
   233 
   234 lemma surjE: "surj f ==> (!!x. y = f x ==> C) ==> C"
   235 by (simp add: surj_def, blast)
   236 
   237 lemma comp_surj: "[| surj f;  surj g |] ==> surj (g o f)"
   238 apply (simp add: comp_def surj_def, clarify)
   239 apply (drule_tac x = y in spec, clarify)
   240 apply (drule_tac x = x in spec, blast)
   241 done
   242 
   243 lemma bijI: "[| inj f; surj f |] ==> bij f"
   244 by (simp add: bij_def)
   245 
   246 lemma bij_is_inj: "bij f ==> inj f"
   247 by (simp add: bij_def)
   248 
   249 lemma bij_is_surj: "bij f ==> surj f"
   250 by (simp add: bij_def)
   251 
   252 lemma bij_betw_imp_inj_on: "bij_betw f A B \<Longrightarrow> inj_on f A"
   253 by (simp add: bij_betw_def)
   254 
   255 lemma bij_betw_inv: assumes "bij_betw f A B" shows "EX g. bij_betw g B A"
   256 proof -
   257   have i: "inj_on f A" and s: "f ` A = B"
   258     using assms by(auto simp:bij_betw_def)
   259   let ?P = "%b a. a:A \<and> f a = b" let ?g = "%b. The (?P b)"
   260   { fix a b assume P: "?P b a"
   261     hence ex1: "\<exists>a. ?P b a" using s unfolding image_def by blast
   262     hence uex1: "\<exists>!a. ?P b a" by(blast dest:inj_onD[OF i])
   263     hence " ?g b = a" using the1_equality[OF uex1, OF P] P by simp
   264   } note g = this
   265   have "inj_on ?g B"
   266   proof(rule inj_onI)
   267     fix x y assume "x:B" "y:B" "?g x = ?g y"
   268     from s `x:B` obtain a1 where a1: "?P x a1" unfolding image_def by blast
   269     from s `y:B` obtain a2 where a2: "?P y a2" unfolding image_def by blast
   270     from g[OF a1] a1 g[OF a2] a2 `?g x = ?g y` show "x=y" by simp
   271   qed
   272   moreover have "?g ` B = A"
   273   proof(auto simp:image_def)
   274     fix b assume "b:B"
   275     with s obtain a where P: "?P b a" unfolding image_def by blast
   276     thus "?g b \<in> A" using g[OF P] by auto
   277   next
   278     fix a assume "a:A"
   279     then obtain b where P: "?P b a" using s unfolding image_def by blast
   280     then have "b:B" using s unfolding image_def by blast
   281     with g[OF P] show "\<exists>b\<in>B. a = ?g b" by blast
   282   qed
   283   ultimately show ?thesis by(auto simp:bij_betw_def)
   284 qed
   285 
   286 lemma surj_image_vimage_eq: "surj f ==> f ` (f -` A) = A"
   287 by (simp add: surj_range)
   288 
   289 lemma inj_vimage_image_eq: "inj f ==> f -` (f ` A) = A"
   290 by (simp add: inj_on_def, blast)
   291 
   292 lemma vimage_subsetD: "surj f ==> f -` B <= A ==> B <= f ` A"
   293 apply (unfold surj_def)
   294 apply (blast intro: sym)
   295 done
   296 
   297 lemma vimage_subsetI: "inj f ==> B <= f ` A ==> f -` B <= A"
   298 by (unfold inj_on_def, blast)
   299 
   300 lemma vimage_subset_eq: "bij f ==> (f -` B <= A) = (B <= f ` A)"
   301 apply (unfold bij_def)
   302 apply (blast del: subsetI intro: vimage_subsetI vimage_subsetD)
   303 done
   304 
   305 lemma inj_on_image_Int:
   306    "[| inj_on f C;  A<=C;  B<=C |] ==> f`(A Int B) = f`A Int f`B"
   307 apply (simp add: inj_on_def, blast)
   308 done
   309 
   310 lemma inj_on_image_set_diff:
   311    "[| inj_on f C;  A<=C;  B<=C |] ==> f`(A-B) = f`A - f`B"
   312 apply (simp add: inj_on_def, blast)
   313 done
   314 
   315 lemma image_Int: "inj f ==> f`(A Int B) = f`A Int f`B"
   316 by (simp add: inj_on_def, blast)
   317 
   318 lemma image_set_diff: "inj f ==> f`(A-B) = f`A - f`B"
   319 by (simp add: inj_on_def, blast)
   320 
   321 lemma inj_image_mem_iff: "inj f ==> (f a : f`A) = (a : A)"
   322 by (blast dest: injD)
   323 
   324 lemma inj_image_subset_iff: "inj f ==> (f`A <= f`B) = (A<=B)"
   325 by (simp add: inj_on_def, blast)
   326 
   327 lemma inj_image_eq_iff: "inj f ==> (f`A = f`B) = (A = B)"
   328 by (blast dest: injD)
   329 
   330 (*injectivity's required.  Left-to-right inclusion holds even if A is empty*)
   331 lemma image_INT:
   332    "[| inj_on f C;  ALL x:A. B x <= C;  j:A |]
   333     ==> f ` (INTER A B) = (INT x:A. f ` B x)"
   334 apply (simp add: inj_on_def, blast)
   335 done
   336 
   337 (*Compare with image_INT: no use of inj_on, and if f is surjective then
   338   it doesn't matter whether A is empty*)
   339 lemma bij_image_INT: "bij f ==> f ` (INTER A B) = (INT x:A. f ` B x)"
   340 apply (simp add: bij_def)
   341 apply (simp add: inj_on_def surj_def, blast)
   342 done
   343 
   344 lemma surj_Compl_image_subset: "surj f ==> -(f`A) <= f`(-A)"
   345 by (auto simp add: surj_def)
   346 
   347 lemma inj_image_Compl_subset: "inj f ==> f`(-A) <= -(f`A)"
   348 by (auto simp add: inj_on_def)
   349 
   350 lemma bij_image_Compl_eq: "bij f ==> f`(-A) = -(f`A)"
   351 apply (simp add: bij_def)
   352 apply (rule equalityI)
   353 apply (simp_all (no_asm_simp) add: inj_image_Compl_subset surj_Compl_image_subset)
   354 done
   355 
   356 
   357 subsection{*Function Updating*}
   358 
   359 constdefs
   360   fun_upd :: "('a => 'b) => 'a => 'b => ('a => 'b)"
   361   "fun_upd f a b == % x. if x=a then b else f x"
   362 
   363 nonterminals
   364   updbinds updbind
   365 syntax
   366   "_updbind" :: "['a, 'a] => updbind"             ("(2_ :=/ _)")
   367   ""         :: "updbind => updbinds"             ("_")
   368   "_updbinds":: "[updbind, updbinds] => updbinds" ("_,/ _")
   369   "_Update"  :: "['a, updbinds] => 'a"            ("_/'((_)')" [1000,0] 900)
   370 
   371 translations
   372   "_Update f (_updbinds b bs)"  == "_Update (_Update f b) bs"
   373   "f(x:=y)"                     == "fun_upd f x y"
   374 
   375 (* Hint: to define the sum of two functions (or maps), use sum_case.
   376          A nice infix syntax could be defined (in Datatype.thy or below) by
   377 consts
   378   fun_sum :: "('a => 'c) => ('b => 'c) => (('a+'b) => 'c)" (infixr "'(+')"80)
   379 translations
   380  "fun_sum" == sum_case
   381 *)
   382 
   383 lemma fun_upd_idem_iff: "(f(x:=y) = f) = (f x = y)"
   384 apply (simp add: fun_upd_def, safe)
   385 apply (erule subst)
   386 apply (rule_tac [2] ext, auto)
   387 done
   388 
   389 (* f x = y ==> f(x:=y) = f *)
   390 lemmas fun_upd_idem = fun_upd_idem_iff [THEN iffD2, standard]
   391 
   392 (* f(x := f x) = f *)
   393 lemmas fun_upd_triv = refl [THEN fun_upd_idem]
   394 declare fun_upd_triv [iff]
   395 
   396 lemma fun_upd_apply [simp]: "(f(x:=y))z = (if z=x then y else f z)"
   397 by (simp add: fun_upd_def)
   398 
   399 (* fun_upd_apply supersedes these two,   but they are useful
   400    if fun_upd_apply is intentionally removed from the simpset *)
   401 lemma fun_upd_same: "(f(x:=y)) x = y"
   402 by simp
   403 
   404 lemma fun_upd_other: "z~=x ==> (f(x:=y)) z = f z"
   405 by simp
   406 
   407 lemma fun_upd_upd [simp]: "f(x:=y,x:=z) = f(x:=z)"
   408 by (simp add: expand_fun_eq)
   409 
   410 lemma fun_upd_twist: "a ~= c ==> (m(a:=b))(c:=d) = (m(c:=d))(a:=b)"
   411 by (rule ext, auto)
   412 
   413 lemma inj_on_fun_updI: "\<lbrakk> inj_on f A; y \<notin> f`A \<rbrakk> \<Longrightarrow> inj_on (f(x:=y)) A"
   414 by(fastsimp simp:inj_on_def image_def)
   415 
   416 lemma fun_upd_image:
   417      "f(x:=y) ` A = (if x \<in> A then insert y (f ` (A-{x})) else f ` A)"
   418 by auto
   419 
   420 
   421 subsection {* @{text override_on} *}
   422 
   423 definition
   424   override_on :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'a \<Rightarrow> 'b"
   425 where
   426   "override_on f g A = (\<lambda>a. if a \<in> A then g a else f a)"
   427 
   428 lemma override_on_emptyset[simp]: "override_on f g {} = f"
   429 by(simp add:override_on_def)
   430 
   431 lemma override_on_apply_notin[simp]: "a ~: A ==> (override_on f g A) a = f a"
   432 by(simp add:override_on_def)
   433 
   434 lemma override_on_apply_in[simp]: "a : A ==> (override_on f g A) a = g a"
   435 by(simp add:override_on_def)
   436 
   437 
   438 subsection {* @{text swap} *}
   439 
   440 definition
   441   swap :: "'a \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)"
   442 where
   443   "swap a b f = f (a := f b, b:= f a)"
   444 
   445 lemma swap_self: "swap a a f = f"
   446 by (simp add: swap_def)
   447 
   448 lemma swap_commute: "swap a b f = swap b a f"
   449 by (rule ext, simp add: fun_upd_def swap_def)
   450 
   451 lemma swap_nilpotent [simp]: "swap a b (swap a b f) = f"
   452 by (rule ext, simp add: fun_upd_def swap_def)
   453 
   454 lemma inj_on_imp_inj_on_swap:
   455   "[|inj_on f A; a \<in> A; b \<in> A|] ==> inj_on (swap a b f) A"
   456 by (simp add: inj_on_def swap_def, blast)
   457 
   458 lemma inj_on_swap_iff [simp]:
   459   assumes A: "a \<in> A" "b \<in> A" shows "inj_on (swap a b f) A = inj_on f A"
   460 proof 
   461   assume "inj_on (swap a b f) A"
   462   with A have "inj_on (swap a b (swap a b f)) A" 
   463     by (iprover intro: inj_on_imp_inj_on_swap) 
   464   thus "inj_on f A" by simp 
   465 next
   466   assume "inj_on f A"
   467   with A show "inj_on (swap a b f) A" by (iprover intro: inj_on_imp_inj_on_swap)
   468 qed
   469 
   470 lemma surj_imp_surj_swap: "surj f ==> surj (swap a b f)"
   471 apply (simp add: surj_def swap_def, clarify)
   472 apply (rule_tac P = "y = f b" in case_split_thm, blast)
   473 apply (rule_tac P = "y = f a" in case_split_thm, auto)
   474   --{*We don't yet have @{text case_tac}*}
   475 done
   476 
   477 lemma surj_swap_iff [simp]: "surj (swap a b f) = surj f"
   478 proof 
   479   assume "surj (swap a b f)"
   480   hence "surj (swap a b (swap a b f))" by (rule surj_imp_surj_swap) 
   481   thus "surj f" by simp 
   482 next
   483   assume "surj f"
   484   thus "surj (swap a b f)" by (rule surj_imp_surj_swap) 
   485 qed
   486 
   487 lemma bij_swap_iff: "bij (swap a b f) = bij f"
   488 by (simp add: bij_def)
   489 
   490 
   491 subsection {* Proof tool setup *} 
   492 
   493 text {* simplifies terms of the form
   494   f(...,x:=y,...,x:=z,...) to f(...,x:=z,...) *}
   495 
   496 simproc_setup fun_upd2 ("f(v := w, x := y)") = {* fn _ =>
   497 let
   498   fun gen_fun_upd NONE T _ _ = NONE
   499     | gen_fun_upd (SOME f) T x y = SOME (Const (@{const_name fun_upd}, T) $ f $ x $ y)
   500   fun dest_fun_T1 (Type (_, T :: Ts)) = T
   501   fun find_double (t as Const (@{const_name fun_upd},T) $ f $ x $ y) =
   502     let
   503       fun find (Const (@{const_name fun_upd},T) $ g $ v $ w) =
   504             if v aconv x then SOME g else gen_fun_upd (find g) T v w
   505         | find t = NONE
   506     in (dest_fun_T1 T, gen_fun_upd (find f) T x y) end
   507 
   508   fun proc ss ct =
   509     let
   510       val ctxt = Simplifier.the_context ss
   511       val t = Thm.term_of ct
   512     in
   513       case find_double t of
   514         (T, NONE) => NONE
   515       | (T, SOME rhs) =>
   516           SOME (Goal.prove ctxt [] [] (Term.equals T $ t $ rhs)
   517             (fn _ =>
   518               rtac eq_reflection 1 THEN
   519               rtac ext 1 THEN
   520               simp_tac (Simplifier.inherit_context ss @{simpset}) 1))
   521     end
   522 in proc end
   523 *}
   524 
   525 
   526 subsection {* Code generator setup *}
   527 
   528 types_code
   529   "fun"  ("(_ ->/ _)")
   530 attach (term_of) {*
   531 fun term_of_fun_type _ aT _ bT _ = Free ("<function>", aT --> bT);
   532 *}
   533 attach (test) {*
   534 fun gen_fun_type aF aT bG bT i =
   535   let
   536     val tab = ref [];
   537     fun mk_upd (x, (_, y)) t = Const ("Fun.fun_upd",
   538       (aT --> bT) --> aT --> bT --> aT --> bT) $ t $ aF x $ y ()
   539   in
   540     (fn x =>
   541        case AList.lookup op = (!tab) x of
   542          NONE =>
   543            let val p as (y, _) = bG i
   544            in (tab := (x, p) :: !tab; y) end
   545        | SOME (y, _) => y,
   546      fn () => Basics.fold mk_upd (!tab) (Const ("arbitrary", aT --> bT)))
   547   end;
   548 *}
   549 
   550 code_const "op \<circ>"
   551   (SML infixl 5 "o")
   552   (Haskell infixr 9 ".")
   553 
   554 code_const "id"
   555   (Haskell "id")
   556 
   557 end