src/HOL/Library/Enum.thy
author haftmann
Fri, 10 Oct 2008 06:45:53 +0200
changeset 28562 4e74209f113e
parent 28245 9767dd8e1e54
child 28684 48faac324061
permissions -rw-r--r--
`code func` now just `code`
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     1
(*  Title:      HOL/Library/Enum.thy
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     2
    ID:         $Id$
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     3
    Author:     Florian Haftmann, TU Muenchen
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     4
*)
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     5
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     6
header {* Finite types as explicit enumerations *}
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     7
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
     8
theory Enum
27487
c8a6ce181805 absolute imports of HOL/*.thy theories
haftmann
parents: 27368
diff changeset
     9
imports Plain "~~/src/HOL/Map"
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    10
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    11
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    12
subsection {* Class @{text enum} *}
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    13
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    14
class enum = itself +
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    15
  fixes enum :: "'a list"
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
    16
  assumes UNIV_enum [code]: "UNIV = set enum"
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    17
    and enum_distinct: "distinct enum"
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    18
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    19
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    20
lemma finite_enum: "finite (UNIV \<Colon> 'a set)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    21
  unfolding UNIV_enum ..
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    22
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    23
lemma enum_all: "set enum = UNIV" unfolding UNIV_enum ..
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    24
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    25
lemma in_enum [intro]: "x \<in> set enum"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    26
  unfolding enum_all by auto
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    27
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    28
lemma enum_eq_I:
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    29
  assumes "\<And>x. x \<in> set xs"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    30
  shows "set enum = set xs"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    31
proof -
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    32
  from assms UNIV_eq_I have "UNIV = set xs" by auto
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    33
  with enum_all show ?thesis by simp
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    34
qed
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    35
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    36
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    37
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    38
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    39
subsection {* Equality and order on functions *}
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    40
26513
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    41
instantiation "fun" :: (enum, eq) eq
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    42
begin
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    43
26513
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    44
definition
26732
6ea9de67e576 constant HOL.eq now qualified
haftmann
parents: 26513
diff changeset
    45
  "eq_class.eq f g \<longleftrightarrow> (\<forall>x \<in> set enum. f x = g x)"
26513
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    46
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    47
instance by default
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    48
  (simp_all add: eq_fun_def enum_all expand_fun_eq)
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    49
6f306c8c2c54 explicit class "eq" for operational equality
haftmann
parents: 26444
diff changeset
    50
end
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    51
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
    52
lemma order_fun [code]:
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    53
  fixes f g :: "'a\<Colon>enum \<Rightarrow> 'b\<Colon>order"
26968
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    54
  shows "f \<le> g \<longleftrightarrow> list_all (\<lambda>x. f x \<le> g x) enum"
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    55
    and "f < g \<longleftrightarrow> f \<le> g \<and> \<not> list_all (\<lambda>x. f x = g x) enum"
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    56
  by (simp_all add: list_all_iff enum_all expand_fun_eq le_fun_def less_fun_def order_less_le)
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    57
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    58
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    59
subsection {* Quantifiers *}
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    60
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
    61
lemma all_code [code]: "(\<forall>x. P x) \<longleftrightarrow> list_all P enum"
26968
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    62
  by (simp add: list_all_iff enum_all)
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    63
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
    64
lemma exists_code [code]: "(\<exists>x. P x) \<longleftrightarrow> \<not> list_all (Not o P) enum"
26968
bb0a56a66180 added code for quantifiers
haftmann
parents: 26815
diff changeset
    65
  by (simp add: list_all_iff enum_all)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    66
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    67
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    68
subsection {* Default instances *}
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
    69
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    70
primrec n_lists :: "nat \<Rightarrow> 'a list \<Rightarrow> 'a list list" where
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    71
  "n_lists 0 xs = [[]]"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    72
  | "n_lists (Suc n) xs = concat (map (\<lambda>ys. map (\<lambda>y. y # ys) xs) (n_lists n xs))"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    73
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    74
lemma n_lists_Nil [simp]: "n_lists n [] = (if n = 0 then [[]] else [])"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    75
  by (induct n) simp_all
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    76
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    77
lemma length_n_lists: "length (n_lists n xs) = length xs ^ n"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    78
  by (induct n) (auto simp add: length_concat map_compose [symmetric] o_def listsum_triv)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    79
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    80
lemma length_n_lists_elem: "ys \<in> set (n_lists n xs) \<Longrightarrow> length ys = n"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    81
  by (induct n arbitrary: ys) auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    82
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    83
lemma set_n_lists: "set (n_lists n xs) = {ys. length ys = n \<and> set ys \<subseteq> set xs}"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    84
proof (rule set_ext)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    85
  fix ys :: "'a list"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    86
  show "ys \<in> set (n_lists n xs) \<longleftrightarrow> ys \<in> {ys. length ys = n \<and> set ys \<subseteq> set xs}"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    87
  proof -
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    88
    have "ys \<in> set (n_lists n xs) \<Longrightarrow> length ys = n"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    89
      by (induct n arbitrary: ys) auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    90
    moreover have "\<And>x. ys \<in> set (n_lists n xs) \<Longrightarrow> x \<in> set ys \<Longrightarrow> x \<in> set xs"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    91
      by (induct n arbitrary: ys) auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    92
    moreover have "set ys \<subseteq> set xs \<Longrightarrow> ys \<in> set (n_lists (length ys) xs)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    93
      by (induct ys) auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    94
    ultimately show ?thesis by auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    95
  qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    96
qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    97
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    98
lemma distinct_n_lists:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
    99
  assumes "distinct xs"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   100
  shows "distinct (n_lists n xs)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   101
proof (rule card_distinct)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   102
  from assms have card_length: "card (set xs) = length xs" by (rule distinct_card)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   103
  have "card (set (n_lists n xs)) = card (set xs) ^ n"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   104
  proof (induct n)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   105
    case 0 then show ?case by simp
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   106
  next
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   107
    case (Suc n)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   108
    moreover have "card (\<Union>ys\<in>set (n_lists n xs). (\<lambda>y. y # ys) ` set xs)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   109
      = (\<Sum>ys\<in>set (n_lists n xs). card ((\<lambda>y. y # ys) ` set xs))"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   110
      by (rule card_UN_disjoint) auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   111
    moreover have "\<And>ys. card ((\<lambda>y. y # ys) ` set xs) = card (set xs)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   112
      by (rule card_image) (simp add: inj_on_def)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   113
    ultimately show ?case by auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   114
  qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   115
  also have "\<dots> = length xs ^ n" by (simp add: card_length)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   116
  finally show "card (set (n_lists n xs)) = length (n_lists n xs)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   117
    by (simp add: length_n_lists)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   118
qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   119
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   120
lemma map_of_zip_map:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   121
  fixes f :: "'a\<Colon>enum \<Rightarrow> 'b\<Colon>enum"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   122
  shows "map_of (zip xs (map f xs)) = (\<lambda>x. if x \<in> set xs then Some (f x) else None)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   123
  by (induct xs) (simp_all add: expand_fun_eq)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   124
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   125
lemma map_of_zip_enum_is_Some:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   126
  assumes "length ys = length (enum \<Colon> 'a\<Colon>enum list)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   127
  shows "\<exists>y. map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x = Some y"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   128
proof -
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   129
  from assms have "x \<in> set (enum \<Colon> 'a\<Colon>enum list) \<longleftrightarrow>
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   130
    (\<exists>y. map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x = Some y)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   131
    by (auto intro!: map_of_zip_is_Some)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   132
  then show ?thesis using enum_all by auto
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   133
qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   134
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   135
lemma map_of_zip_enum_inject:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   136
  fixes xs ys :: "'b\<Colon>enum list"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   137
  assumes length: "length xs = length (enum \<Colon> 'a\<Colon>enum list)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   138
      "length ys = length (enum \<Colon> 'a\<Colon>enum list)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   139
    and map_of: "the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) = the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   140
  shows "xs = ys"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   141
proof -
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   142
  have "map_of (zip (enum \<Colon> 'a list) xs) = map_of (zip (enum \<Colon> 'a list) ys)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   143
  proof
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   144
    fix x :: 'a
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   145
    from length map_of_zip_enum_is_Some obtain y1 y2
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   146
      where "map_of (zip (enum \<Colon> 'a list) xs) x = Some y1"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   147
        and "map_of (zip (enum \<Colon> 'a list) ys) x = Some y2" by blast
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   148
    moreover from map_of have "the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x) = the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   149
      by (auto dest: fun_cong)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   150
    ultimately show "map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x = map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   151
      by simp
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   152
  qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   153
  with length enum_distinct show "xs = ys" by (rule map_of_zip_inject)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   154
qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   155
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   156
instantiation "fun" :: (enum, enum) enum
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   157
begin
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   158
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   159
definition
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
   160
  [code del]: "enum = map (\<lambda>ys. the o map_of (zip (enum\<Colon>'a list) ys)) (n_lists (length (enum\<Colon>'a\<Colon>enum list)) enum)"
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   161
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   162
instance proof
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   163
  show "UNIV = set (enum \<Colon> ('a \<Rightarrow> 'b) list)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   164
  proof (rule UNIV_eq_I)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   165
    fix f :: "'a \<Rightarrow> 'b"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   166
    have "f = the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) (map f enum))"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   167
      by (auto simp add: map_of_zip_map expand_fun_eq)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   168
    then show "f \<in> set enum"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   169
      by (auto simp add: enum_fun_def set_n_lists)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   170
  qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   171
next
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   172
  from map_of_zip_enum_inject
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   173
  show "distinct (enum \<Colon> ('a \<Rightarrow> 'b) list)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   174
    by (auto intro!: inj_onI simp add: enum_fun_def
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   175
      distinct_map distinct_n_lists enum_distinct set_n_lists enum_all)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   176
qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   177
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   178
end
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   179
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
   180
lemma enum_fun_code [code]: "enum = (let enum_a = (enum \<Colon> 'a\<Colon>{enum, eq} list)
28245
9767dd8e1e54 celver code lemma avoid type ambiguity problem with Haskell
haftmann
parents: 27487
diff changeset
   181
  in map (\<lambda>ys. the o map_of (zip enum_a ys)) (n_lists (length enum_a) enum))"
9767dd8e1e54 celver code lemma avoid type ambiguity problem with Haskell
haftmann
parents: 27487
diff changeset
   182
  by (simp add: enum_fun_def Let_def)
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   183
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   184
instantiation unit :: enum
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   185
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   186
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   187
definition
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   188
  "enum = [()]"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   189
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   190
instance by default
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   191
  (simp_all add: enum_unit_def UNIV_unit)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   192
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   193
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   194
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   195
instantiation bool :: enum
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   196
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   197
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   198
definition
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   199
  "enum = [False, True]"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   200
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   201
instance by default
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   202
  (simp_all add: enum_bool_def UNIV_bool)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   203
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   204
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   205
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   206
primrec product :: "'a list \<Rightarrow> 'b list \<Rightarrow> ('a \<times> 'b) list" where
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   207
  "product [] _ = []"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   208
  | "product (x#xs) ys = map (Pair x) ys @ product xs ys"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   209
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   210
lemma product_list_set:
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   211
  "set (product xs ys) = set xs \<times> set ys"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   212
  by (induct xs) auto
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   213
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   214
lemma distinct_product:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   215
  assumes "distinct xs" and "distinct ys"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   216
  shows "distinct (product xs ys)"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   217
  using assms by (induct xs)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   218
    (auto intro: inj_onI simp add: product_list_set distinct_map)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   219
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   220
instantiation * :: (enum, enum) enum
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   221
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   222
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   223
definition
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   224
  "enum = product enum enum"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   225
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   226
instance by default
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   227
  (simp_all add: enum_prod_def product_list_set distinct_product enum_all enum_distinct)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   228
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   229
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   230
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   231
instantiation "+" :: (enum, enum) enum
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   232
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   233
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   234
definition
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   235
  "enum = map Inl enum @ map Inr enum"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   236
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   237
instance by default
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   238
  (auto simp add: enum_all enum_sum_def, case_tac x, auto intro: inj_onI simp add: distinct_map enum_distinct)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   239
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   240
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   241
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   242
primrec sublists :: "'a list \<Rightarrow> 'a list list" where
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   243
  "sublists [] = [[]]"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   244
  | "sublists (x#xs) = (let xss = sublists xs in map (Cons x) xss @ xss)"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   245
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   246
lemma length_sublists:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   247
  "length (sublists xs) = Suc (Suc (0\<Colon>nat)) ^ length xs"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   248
  by (induct xs) (simp_all add: Let_def)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   249
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   250
lemma sublists_powset:
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   251
  "set ` set (sublists xs) = Pow (set xs)"
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   252
proof -
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   253
  have aux: "\<And>x A. set ` Cons x ` A = insert x ` set ` A"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   254
    by (auto simp add: image_def)
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   255
  have "set (map set (sublists xs)) = Pow (set xs)"
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   256
    by (induct xs)
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   257
      (simp_all add: aux Let_def Pow_insert Un_commute)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   258
  then show ?thesis by simp
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   259
qed
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   260
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   261
lemma distinct_set_sublists:
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   262
  assumes "distinct xs"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   263
  shows "distinct (map set (sublists xs))"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   264
proof (rule card_distinct)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   265
  have "finite (set xs)" by rule
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   266
  then have "card (Pow (set xs)) = Suc (Suc 0) ^ card (set xs)" by (rule card_Pow)
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   267
  with assms distinct_card [of xs]
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   268
    have "card (Pow (set xs)) = Suc (Suc 0) ^ length xs" by simp
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   269
  then show "card (set (map set (sublists xs))) = length (map set (sublists xs))"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   270
    by (simp add: sublists_powset length_sublists)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   271
qed
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   272
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   273
instantiation nibble :: enum
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   274
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   275
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   276
definition
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   277
  "enum = [Nibble0, Nibble1, Nibble2, Nibble3, Nibble4, Nibble5, Nibble6, Nibble7,
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   278
    Nibble8, Nibble9, NibbleA, NibbleB, NibbleC, NibbleD, NibbleE, NibbleF]"
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   279
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   280
instance by default
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   281
  (simp_all add: enum_nibble_def UNIV_nibble)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   282
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   283
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   284
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   285
instantiation char :: enum
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   286
begin
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   287
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   288
definition
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
   289
  [code del]: "enum = map (split Char) (product enum enum)"
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   290
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28245
diff changeset
   291
lemma enum_char [code]:
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   292
  "enum = [Char Nibble0 Nibble0, Char Nibble0 Nibble1, Char Nibble0 Nibble2,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   293
  Char Nibble0 Nibble3, Char Nibble0 Nibble4, Char Nibble0 Nibble5,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   294
  Char Nibble0 Nibble6, Char Nibble0 Nibble7, Char Nibble0 Nibble8,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   295
  Char Nibble0 Nibble9, Char Nibble0 NibbleA, Char Nibble0 NibbleB,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   296
  Char Nibble0 NibbleC, Char Nibble0 NibbleD, Char Nibble0 NibbleE,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   297
  Char Nibble0 NibbleF, Char Nibble1 Nibble0, Char Nibble1 Nibble1,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   298
  Char Nibble1 Nibble2, Char Nibble1 Nibble3, Char Nibble1 Nibble4,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   299
  Char Nibble1 Nibble5, Char Nibble1 Nibble6, Char Nibble1 Nibble7,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   300
  Char Nibble1 Nibble8, Char Nibble1 Nibble9, Char Nibble1 NibbleA,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   301
  Char Nibble1 NibbleB, Char Nibble1 NibbleC, Char Nibble1 NibbleD,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   302
  Char Nibble1 NibbleE, Char Nibble1 NibbleF, CHR '' '', CHR ''!'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   303
  Char Nibble2 Nibble2, CHR ''#'', CHR ''$'', CHR ''%'', CHR ''&'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   304
  Char Nibble2 Nibble7, CHR ''('', CHR '')'', CHR ''*'', CHR ''+'', CHR '','',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   305
  CHR ''-'', CHR ''.'', CHR ''/'', CHR ''0'', CHR ''1'', CHR ''2'', CHR ''3'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   306
  CHR ''4'', CHR ''5'', CHR ''6'', CHR ''7'', CHR ''8'', CHR ''9'', CHR '':'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   307
  CHR '';'', CHR ''<'', CHR ''='', CHR ''>'', CHR ''?'', CHR ''@'', CHR ''A'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   308
  CHR ''B'', CHR ''C'', CHR ''D'', CHR ''E'', CHR ''F'', CHR ''G'', CHR ''H'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   309
  CHR ''I'', CHR ''J'', CHR ''K'', CHR ''L'', CHR ''M'', CHR ''N'', CHR ''O'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   310
  CHR ''P'', CHR ''Q'', CHR ''R'', CHR ''S'', CHR ''T'', CHR ''U'', CHR ''V'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   311
  CHR ''W'', CHR ''X'', CHR ''Y'', CHR ''Z'', CHR ''['', Char Nibble5 NibbleC,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   312
  CHR '']'', CHR ''^'', CHR ''_'', Char Nibble6 Nibble0, CHR ''a'', CHR ''b'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   313
  CHR ''c'', CHR ''d'', CHR ''e'', CHR ''f'', CHR ''g'', CHR ''h'', CHR ''i'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   314
  CHR ''j'', CHR ''k'', CHR ''l'', CHR ''m'', CHR ''n'', CHR ''o'', CHR ''p'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   315
  CHR ''q'', CHR ''r'', CHR ''s'', CHR ''t'', CHR ''u'', CHR ''v'', CHR ''w'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   316
  CHR ''x'', CHR ''y'', CHR ''z'', CHR ''{'', CHR ''|'', CHR ''}'', CHR ''~'',
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   317
  Char Nibble7 NibbleF, Char Nibble8 Nibble0, Char Nibble8 Nibble1,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   318
  Char Nibble8 Nibble2, Char Nibble8 Nibble3, Char Nibble8 Nibble4,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   319
  Char Nibble8 Nibble5, Char Nibble8 Nibble6, Char Nibble8 Nibble7,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   320
  Char Nibble8 Nibble8, Char Nibble8 Nibble9, Char Nibble8 NibbleA,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   321
  Char Nibble8 NibbleB, Char Nibble8 NibbleC, Char Nibble8 NibbleD,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   322
  Char Nibble8 NibbleE, Char Nibble8 NibbleF, Char Nibble9 Nibble0,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   323
  Char Nibble9 Nibble1, Char Nibble9 Nibble2, Char Nibble9 Nibble3,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   324
  Char Nibble9 Nibble4, Char Nibble9 Nibble5, Char Nibble9 Nibble6,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   325
  Char Nibble9 Nibble7, Char Nibble9 Nibble8, Char Nibble9 Nibble9,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   326
  Char Nibble9 NibbleA, Char Nibble9 NibbleB, Char Nibble9 NibbleC,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   327
  Char Nibble9 NibbleD, Char Nibble9 NibbleE, Char Nibble9 NibbleF,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   328
  Char NibbleA Nibble0, Char NibbleA Nibble1, Char NibbleA Nibble2,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   329
  Char NibbleA Nibble3, Char NibbleA Nibble4, Char NibbleA Nibble5,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   330
  Char NibbleA Nibble6, Char NibbleA Nibble7, Char NibbleA Nibble8,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   331
  Char NibbleA Nibble9, Char NibbleA NibbleA, Char NibbleA NibbleB,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   332
  Char NibbleA NibbleC, Char NibbleA NibbleD, Char NibbleA NibbleE,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   333
  Char NibbleA NibbleF, Char NibbleB Nibble0, Char NibbleB Nibble1,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   334
  Char NibbleB Nibble2, Char NibbleB Nibble3, Char NibbleB Nibble4,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   335
  Char NibbleB Nibble5, Char NibbleB Nibble6, Char NibbleB Nibble7,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   336
  Char NibbleB Nibble8, Char NibbleB Nibble9, Char NibbleB NibbleA,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   337
  Char NibbleB NibbleB, Char NibbleB NibbleC, Char NibbleB NibbleD,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   338
  Char NibbleB NibbleE, Char NibbleB NibbleF, Char NibbleC Nibble0,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   339
  Char NibbleC Nibble1, Char NibbleC Nibble2, Char NibbleC Nibble3,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   340
  Char NibbleC Nibble4, Char NibbleC Nibble5, Char NibbleC Nibble6,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   341
  Char NibbleC Nibble7, Char NibbleC Nibble8, Char NibbleC Nibble9,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   342
  Char NibbleC NibbleA, Char NibbleC NibbleB, Char NibbleC NibbleC,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   343
  Char NibbleC NibbleD, Char NibbleC NibbleE, Char NibbleC NibbleF,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   344
  Char NibbleD Nibble0, Char NibbleD Nibble1, Char NibbleD Nibble2,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   345
  Char NibbleD Nibble3, Char NibbleD Nibble4, Char NibbleD Nibble5,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   346
  Char NibbleD Nibble6, Char NibbleD Nibble7, Char NibbleD Nibble8,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   347
  Char NibbleD Nibble9, Char NibbleD NibbleA, Char NibbleD NibbleB,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   348
  Char NibbleD NibbleC, Char NibbleD NibbleD, Char NibbleD NibbleE,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   349
  Char NibbleD NibbleF, Char NibbleE Nibble0, Char NibbleE Nibble1,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   350
  Char NibbleE Nibble2, Char NibbleE Nibble3, Char NibbleE Nibble4,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   351
  Char NibbleE Nibble5, Char NibbleE Nibble6, Char NibbleE Nibble7,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   352
  Char NibbleE Nibble8, Char NibbleE Nibble9, Char NibbleE NibbleA,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   353
  Char NibbleE NibbleB, Char NibbleE NibbleC, Char NibbleE NibbleD,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   354
  Char NibbleE NibbleE, Char NibbleE NibbleF, Char NibbleF Nibble0,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   355
  Char NibbleF Nibble1, Char NibbleF Nibble2, Char NibbleF Nibble3,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   356
  Char NibbleF Nibble4, Char NibbleF Nibble5, Char NibbleF Nibble6,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   357
  Char NibbleF Nibble7, Char NibbleF Nibble8, Char NibbleF Nibble9,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   358
  Char NibbleF NibbleA, Char NibbleF NibbleB, Char NibbleF NibbleC,
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   359
  Char NibbleF NibbleD, Char NibbleF NibbleE, Char NibbleF NibbleF]"
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   360
  unfolding enum_char_def enum_nibble_def by simp
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   361
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   362
instance by default
26444
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   363
  (auto intro: char.exhaust injI simp add: enum_char_def product_list_set enum_all full_SetCompr_eq [symmetric]
6a5faa5bcf19 instance for functions, explicit characters
haftmann
parents: 26348
diff changeset
   364
    distinct_map distinct_product enum_distinct)
26348
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   365
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   366
end
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   367
0f8e23edd357 added theory Library/Enum.thy
haftmann
parents:
diff changeset
   368
end