src/HOL/Library/Dlist.thy
author Manuel Eberl <eberlm@in.tum.de>
Mon Mar 26 16:14:16 2018 +0200 (18 months ago)
changeset 67951 655aa11359dc
parent 67399 eab6ce8368fa
child 69593 3dda49e08b9d
permissions -rw-r--r--
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
Andreas@62139
     1
(* Author: Florian Haftmann, TU Muenchen 
Andreas@62139
     2
   Author: Andreas Lochbihler, ETH Zurich *)
haftmann@35303
     3
wenzelm@60500
     4
section \<open>Lists with elements distinct as canonical example for datatype invariants\<close>
haftmann@35303
     5
haftmann@35303
     6
theory Dlist
haftmann@45990
     7
imports Main
haftmann@35303
     8
begin
haftmann@35303
     9
wenzelm@60500
    10
subsection \<open>The type of distinct lists\<close>
haftmann@35303
    11
wenzelm@49834
    12
typedef 'a dlist = "{xs::'a list. distinct xs}"
haftmann@35303
    13
  morphisms list_of_dlist Abs_dlist
haftmann@35303
    14
proof
wenzelm@45694
    15
  show "[] \<in> {xs. distinct xs}" by simp
haftmann@35303
    16
qed
haftmann@35303
    17
Andreas@62139
    18
setup_lifting type_definition_dlist
Andreas@62139
    19
haftmann@39380
    20
lemma dlist_eq_iff:
haftmann@39380
    21
  "dxs = dys \<longleftrightarrow> list_of_dlist dxs = list_of_dlist dys"
haftmann@39380
    22
  by (simp add: list_of_dlist_inject)
haftmann@36274
    23
haftmann@39380
    24
lemma dlist_eqI:
haftmann@39380
    25
  "list_of_dlist dxs = list_of_dlist dys \<Longrightarrow> dxs = dys"
haftmann@39380
    26
  by (simp add: dlist_eq_iff)
haftmann@36112
    27
wenzelm@60500
    28
text \<open>Formal, totalized constructor for @{typ "'a dlist"}:\<close>
haftmann@35303
    29
haftmann@35303
    30
definition Dlist :: "'a list \<Rightarrow> 'a dlist" where
haftmann@37765
    31
  "Dlist xs = Abs_dlist (remdups xs)"
haftmann@35303
    32
haftmann@39380
    33
lemma distinct_list_of_dlist [simp, intro]:
haftmann@35303
    34
  "distinct (list_of_dlist dxs)"
haftmann@35303
    35
  using list_of_dlist [of dxs] by simp
haftmann@35303
    36
haftmann@35303
    37
lemma list_of_dlist_Dlist [simp]:
haftmann@35303
    38
  "list_of_dlist (Dlist xs) = remdups xs"
haftmann@35303
    39
  by (simp add: Dlist_def Abs_dlist_inverse)
haftmann@35303
    40
haftmann@39727
    41
lemma remdups_list_of_dlist [simp]:
haftmann@39727
    42
  "remdups (list_of_dlist dxs) = list_of_dlist dxs"
haftmann@39727
    43
  by simp
haftmann@39727
    44
haftmann@36112
    45
lemma Dlist_list_of_dlist [simp, code abstype]:
haftmann@35303
    46
  "Dlist (list_of_dlist dxs) = dxs"
haftmann@35303
    47
  by (simp add: Dlist_def list_of_dlist_inverse distinct_remdups_id)
haftmann@35303
    48
haftmann@35303
    49
wenzelm@60500
    50
text \<open>Fundamental operations:\<close>
haftmann@35303
    51
wenzelm@61115
    52
context
wenzelm@61115
    53
begin
wenzelm@61115
    54
wenzelm@61115
    55
qualified definition empty :: "'a dlist" where
haftmann@35303
    56
  "empty = Dlist []"
haftmann@35303
    57
wenzelm@61115
    58
qualified definition insert :: "'a \<Rightarrow> 'a dlist \<Rightarrow> 'a dlist" where
haftmann@35303
    59
  "insert x dxs = Dlist (List.insert x (list_of_dlist dxs))"
haftmann@35303
    60
wenzelm@61115
    61
qualified definition remove :: "'a \<Rightarrow> 'a dlist \<Rightarrow> 'a dlist" where
haftmann@35303
    62
  "remove x dxs = Dlist (remove1 x (list_of_dlist dxs))"
haftmann@35303
    63
wenzelm@61115
    64
qualified definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a dlist \<Rightarrow> 'b dlist" where
haftmann@35303
    65
  "map f dxs = Dlist (remdups (List.map f (list_of_dlist dxs)))"
haftmann@35303
    66
wenzelm@61115
    67
qualified definition filter :: "('a \<Rightarrow> bool) \<Rightarrow> 'a dlist \<Rightarrow> 'a dlist" where
haftmann@35303
    68
  "filter P dxs = Dlist (List.filter P (list_of_dlist dxs))"
haftmann@35303
    69
haftmann@63375
    70
qualified definition rotate :: "nat \<Rightarrow> 'a dlist \<Rightarrow> 'a dlist" where
haftmann@63375
    71
  "rotate n dxs = Dlist (List.rotate n (list_of_dlist dxs))"
haftmann@63375
    72
wenzelm@61115
    73
end
wenzelm@61115
    74
haftmann@35303
    75
wenzelm@60500
    76
text \<open>Derived operations:\<close>
haftmann@35303
    77
wenzelm@61115
    78
context
wenzelm@61115
    79
begin
wenzelm@61115
    80
wenzelm@61115
    81
qualified definition null :: "'a dlist \<Rightarrow> bool" where
haftmann@35303
    82
  "null dxs = List.null (list_of_dlist dxs)"
haftmann@35303
    83
wenzelm@61115
    84
qualified definition member :: "'a dlist \<Rightarrow> 'a \<Rightarrow> bool" where
haftmann@35303
    85
  "member dxs = List.member (list_of_dlist dxs)"
haftmann@35303
    86
wenzelm@61115
    87
qualified definition length :: "'a dlist \<Rightarrow> nat" where
haftmann@35303
    88
  "length dxs = List.length (list_of_dlist dxs)"
haftmann@35303
    89
wenzelm@61115
    90
qualified definition fold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a dlist \<Rightarrow> 'b \<Rightarrow> 'b" where
haftmann@46133
    91
  "fold f dxs = List.fold f (list_of_dlist dxs)"
haftmann@37022
    92
wenzelm@61115
    93
qualified definition foldr :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a dlist \<Rightarrow> 'b \<Rightarrow> 'b" where
haftmann@37022
    94
  "foldr f dxs = List.foldr f (list_of_dlist dxs)"
haftmann@35303
    95
wenzelm@61115
    96
end
wenzelm@61115
    97
haftmann@35303
    98
wenzelm@60500
    99
subsection \<open>Executable version obeying invariant\<close>
haftmann@35303
   100
haftmann@35303
   101
lemma list_of_dlist_empty [simp, code abstract]:
wenzelm@61115
   102
  "list_of_dlist Dlist.empty = []"
wenzelm@61115
   103
  by (simp add: Dlist.empty_def)
haftmann@35303
   104
haftmann@35303
   105
lemma list_of_dlist_insert [simp, code abstract]:
wenzelm@61115
   106
  "list_of_dlist (Dlist.insert x dxs) = List.insert x (list_of_dlist dxs)"
wenzelm@61115
   107
  by (simp add: Dlist.insert_def)
haftmann@35303
   108
haftmann@35303
   109
lemma list_of_dlist_remove [simp, code abstract]:
wenzelm@61115
   110
  "list_of_dlist (Dlist.remove x dxs) = remove1 x (list_of_dlist dxs)"
wenzelm@61115
   111
  by (simp add: Dlist.remove_def)
haftmann@35303
   112
haftmann@35303
   113
lemma list_of_dlist_map [simp, code abstract]:
wenzelm@61115
   114
  "list_of_dlist (Dlist.map f dxs) = remdups (List.map f (list_of_dlist dxs))"
wenzelm@61115
   115
  by (simp add: Dlist.map_def)
haftmann@35303
   116
haftmann@35303
   117
lemma list_of_dlist_filter [simp, code abstract]:
wenzelm@61115
   118
  "list_of_dlist (Dlist.filter P dxs) = List.filter P (list_of_dlist dxs)"
wenzelm@61115
   119
  by (simp add: Dlist.filter_def)
haftmann@35303
   120
haftmann@63375
   121
lemma list_of_dlist_rotate [simp, code abstract]:
haftmann@63375
   122
  "list_of_dlist (Dlist.rotate n dxs) = List.rotate n (list_of_dlist dxs)"
haftmann@63375
   123
  by (simp add: Dlist.rotate_def)
haftmann@63375
   124
haftmann@35303
   125
wenzelm@60500
   126
text \<open>Explicit executable conversion\<close>
haftmann@36980
   127
haftmann@36980
   128
definition dlist_of_list [simp]:
haftmann@36980
   129
  "dlist_of_list = Dlist"
haftmann@36980
   130
haftmann@36980
   131
lemma [code abstract]:
haftmann@36980
   132
  "list_of_dlist (dlist_of_list xs) = remdups xs"
haftmann@36980
   133
  by simp
haftmann@36980
   134
haftmann@36980
   135
wenzelm@60500
   136
text \<open>Equality\<close>
haftmann@38512
   137
haftmann@38857
   138
instantiation dlist :: (equal) equal
haftmann@38512
   139
begin
haftmann@38512
   140
haftmann@38857
   141
definition "HOL.equal dxs dys \<longleftrightarrow> HOL.equal (list_of_dlist dxs) (list_of_dlist dys)"
haftmann@38512
   142
wenzelm@60679
   143
instance
wenzelm@60679
   144
  by standard (simp add: equal_dlist_def equal list_of_dlist_inject)
haftmann@38512
   145
haftmann@38512
   146
end
haftmann@38512
   147
haftmann@43764
   148
declare equal_dlist_def [code]
haftmann@43764
   149
wenzelm@60679
   150
lemma [code nbe]: "HOL.equal (dxs :: 'a::equal dlist) dxs \<longleftrightarrow> True"
haftmann@38857
   151
  by (fact equal_refl)
haftmann@38857
   152
haftmann@38512
   153
wenzelm@60500
   154
subsection \<open>Induction principle and case distinction\<close>
haftmann@37106
   155
haftmann@37106
   156
lemma dlist_induct [case_names empty insert, induct type: dlist]:
wenzelm@61115
   157
  assumes empty: "P Dlist.empty"
wenzelm@61115
   158
  assumes insrt: "\<And>x dxs. \<not> Dlist.member dxs x \<Longrightarrow> P dxs \<Longrightarrow> P (Dlist.insert x dxs)"
haftmann@37106
   159
  shows "P dxs"
haftmann@37106
   160
proof (cases dxs)
haftmann@37106
   161
  case (Abs_dlist xs)
wenzelm@61115
   162
  then have "distinct xs" and dxs: "dxs = Dlist xs"
wenzelm@61115
   163
    by (simp_all add: Dlist_def distinct_remdups_id)
wenzelm@60500
   164
  from \<open>distinct xs\<close> have "P (Dlist xs)"
haftmann@39915
   165
  proof (induct xs)
wenzelm@61115
   166
    case Nil from empty show ?case by (simp add: Dlist.empty_def)
haftmann@37106
   167
  next
haftmann@40122
   168
    case (Cons x xs)
wenzelm@61115
   169
    then have "\<not> Dlist.member (Dlist xs) x" and "P (Dlist xs)"
wenzelm@61115
   170
      by (simp_all add: Dlist.member_def List.member_def)
wenzelm@61115
   171
    with insrt have "P (Dlist.insert x (Dlist xs))" .
wenzelm@61115
   172
    with Cons show ?case by (simp add: Dlist.insert_def distinct_remdups_id)
haftmann@37106
   173
  qed
haftmann@37106
   174
  with dxs show "P dxs" by simp
haftmann@37106
   175
qed
haftmann@37106
   176
wenzelm@55913
   177
lemma dlist_case [cases type: dlist]:
wenzelm@61115
   178
  obtains (empty) "dxs = Dlist.empty"
wenzelm@61115
   179
    | (insert) x dys where "\<not> Dlist.member dys x" and "dxs = Dlist.insert x dys"
haftmann@37106
   180
proof (cases dxs)
haftmann@37106
   181
  case (Abs_dlist xs)
haftmann@37106
   182
  then have dxs: "dxs = Dlist xs" and distinct: "distinct xs"
haftmann@37106
   183
    by (simp_all add: Dlist_def distinct_remdups_id)
wenzelm@55913
   184
  show thesis
wenzelm@55913
   185
  proof (cases xs)
wenzelm@55913
   186
    case Nil with dxs
wenzelm@61115
   187
    have "dxs = Dlist.empty" by (simp add: Dlist.empty_def) 
wenzelm@55913
   188
    with empty show ?thesis .
haftmann@37106
   189
  next
haftmann@37106
   190
    case (Cons x xs)
wenzelm@61115
   191
    with dxs distinct have "\<not> Dlist.member (Dlist xs) x"
wenzelm@61115
   192
      and "dxs = Dlist.insert x (Dlist xs)"
wenzelm@61115
   193
      by (simp_all add: Dlist.member_def List.member_def Dlist.insert_def distinct_remdups_id)
wenzelm@55913
   194
    with insert show ?thesis .
haftmann@37106
   195
  qed
haftmann@37106
   196
qed
haftmann@37106
   197
haftmann@37106
   198
wenzelm@60500
   199
subsection \<open>Functorial structure\<close>
haftmann@40603
   200
blanchet@55467
   201
functor map: map
wenzelm@61115
   202
  by (simp_all add: remdups_map_remdups fun_eq_iff dlist_eq_iff)
haftmann@40603
   203
haftmann@48282
   204
wenzelm@60500
   205
subsection \<open>Quickcheck generators\<close>
bulwahn@45927
   206
wenzelm@61115
   207
quickcheck_generator dlist predicate: distinct constructors: Dlist.empty, Dlist.insert
haftmann@35303
   208
Andreas@62139
   209
subsection \<open>BNF instance\<close>
Andreas@62139
   210
Andreas@62139
   211
context begin
Andreas@62139
   212
Andreas@62139
   213
qualified fun wpull :: "('a \<times> 'b) list \<Rightarrow> ('b \<times> 'c) list \<Rightarrow> ('a \<times> 'c) list"
Andreas@62139
   214
where
Andreas@62139
   215
  "wpull [] ys = []"
Andreas@62139
   216
| "wpull xs [] = []"
Andreas@62139
   217
| "wpull ((a, b) # xs) ((b', c) # ys) =
Andreas@62139
   218
  (if b \<in> snd ` set xs then
Andreas@62139
   219
     (a, the (map_of (rev ((b', c) # ys)) b)) # wpull xs ((b', c) # ys)
Andreas@62139
   220
   else if b' \<in> fst ` set ys then
Andreas@62139
   221
     (the (map_of (map prod.swap (rev ((a, b) # xs))) b'), c) # wpull ((a, b) # xs) ys
Andreas@62139
   222
   else (a, c) # wpull xs ys)"
Andreas@62139
   223
Andreas@62139
   224
qualified lemma wpull_eq_Nil_iff [simp]: "wpull xs ys = [] \<longleftrightarrow> xs = [] \<or> ys = []"
Andreas@62139
   225
by(cases "(xs, ys)" rule: wpull.cases) simp_all
Andreas@62139
   226
Andreas@62139
   227
qualified lemma wpull_induct
Andreas@62139
   228
  [consumes 1, 
Andreas@62139
   229
   case_names Nil left[xs eq in_set IH] right[xs ys eq in_set IH] step[xs ys eq IH] ]:
Andreas@62139
   230
  assumes eq: "remdups (map snd xs) = remdups (map fst ys)"
Andreas@62139
   231
  and Nil: "P [] []"
Andreas@62139
   232
  and left: "\<And>a b xs b' c ys.
Andreas@62139
   233
    \<lbrakk> b \<in> snd ` set xs; remdups (map snd xs) = remdups (map fst ((b', c) # ys)); 
Andreas@62139
   234
      (b, the (map_of (rev ((b', c) # ys)) b)) \<in> set ((b', c) # ys); P xs ((b', c) # ys) \<rbrakk>
Andreas@62139
   235
    \<Longrightarrow> P ((a, b) # xs) ((b', c) # ys)"
Andreas@62139
   236
  and right: "\<And>a b xs b' c ys.
Andreas@62139
   237
    \<lbrakk> b \<notin> snd ` set xs; b' \<in> fst ` set ys;
Andreas@62139
   238
      remdups (map snd ((a, b) # xs)) = remdups (map fst ys);
Andreas@62139
   239
      (the (map_of (map prod.swap (rev ((a, b) #xs))) b'), b') \<in> set ((a, b) # xs);
Andreas@62139
   240
      P ((a, b) # xs) ys \<rbrakk>
Andreas@62139
   241
    \<Longrightarrow> P ((a, b) # xs) ((b', c) # ys)"
Andreas@62139
   242
  and step: "\<And>a b xs c ys.
Andreas@62139
   243
    \<lbrakk> b \<notin> snd ` set xs; b \<notin> fst ` set ys; remdups (map snd xs) = remdups (map fst ys); 
Andreas@62139
   244
      P xs ys \<rbrakk>
Andreas@62139
   245
    \<Longrightarrow> P ((a, b) # xs) ((b, c) # ys)"
Andreas@62139
   246
  shows "P xs ys"
Andreas@62139
   247
using eq
Andreas@62139
   248
proof(induction xs ys rule: wpull.induct)
Andreas@62139
   249
  case 1 thus ?case by(simp add: Nil)
Andreas@62139
   250
next
nipkow@62390
   251
  case 2 thus ?case by(simp split: if_split_asm)
Andreas@62139
   252
next
Andreas@62139
   253
  case Cons: (3 a b xs b' c ys)
Andreas@62139
   254
  let ?xs = "(a, b) # xs" and ?ys = "(b', c) # ys"
Andreas@62139
   255
  consider (xs) "b \<in> snd ` set xs" | (ys) "b \<notin> snd ` set xs" "b' \<in> fst ` set ys"
Andreas@62139
   256
    | (step) "b \<notin> snd ` set xs" "b' \<notin> fst ` set ys" by auto
Andreas@62139
   257
  thus ?case
Andreas@62139
   258
  proof cases
Andreas@62139
   259
    case xs
Andreas@62139
   260
    with Cons.prems have eq: "remdups (map snd xs) = remdups (map fst ?ys)" by auto
Andreas@62139
   261
    from xs eq have "b \<in> fst ` set ?ys" by (metis list.set_map set_remdups)
Andreas@62139
   262
    hence "map_of (rev ?ys) b \<noteq> None" unfolding map_of_eq_None_iff by auto
Andreas@62139
   263
    then obtain c' where "map_of (rev ?ys) b = Some c'" by blast
nipkow@62390
   264
    then have "(b, the (map_of (rev ?ys) b)) \<in> set ?ys" by(auto dest: map_of_SomeD split: if_split_asm)
Andreas@62139
   265
    from xs eq this Cons.IH(1)[OF xs eq] show ?thesis by(rule left)
Andreas@62139
   266
  next
Andreas@62139
   267
    case ys
Andreas@62139
   268
    from ys Cons.prems have eq: "remdups (map snd ?xs) = remdups (map fst ys)" by auto
Andreas@62139
   269
    from ys eq have "b' \<in> snd ` set ?xs" by (metis list.set_map set_remdups)
Andreas@62139
   270
    hence "map_of (map prod.swap (rev ?xs)) b' \<noteq> None"
Andreas@62139
   271
      unfolding map_of_eq_None_iff by(auto simp add: image_image)
Andreas@62139
   272
    then obtain a' where "map_of (map prod.swap (rev ?xs)) b' = Some a'" by blast
Andreas@62139
   273
    then have "(the (map_of (map prod.swap (rev ?xs)) b'), b') \<in> set ?xs"
nipkow@62390
   274
      by(auto dest: map_of_SomeD split: if_split_asm)
Andreas@62139
   275
    from ys eq this Cons.IH(2)[OF ys eq] show ?thesis by(rule right)
Andreas@62139
   276
  next
Andreas@62139
   277
    case *: step
Andreas@62139
   278
    hence "remdups (map snd xs) = remdups (map fst ys)" "b = b'" using Cons.prems by auto
Andreas@62139
   279
    from * this(1) Cons.IH(3)[OF * this(1)] show ?thesis unfolding \<open>b = b'\<close> by(rule step)
Andreas@62139
   280
  qed
Andreas@62139
   281
qed
Andreas@62139
   282
Andreas@62139
   283
qualified lemma set_wpull_subset:
Andreas@62139
   284
  assumes "remdups (map snd xs) = remdups (map fst ys)"
Andreas@62139
   285
  shows "set (wpull xs ys) \<subseteq> set xs O set ys"
Andreas@62139
   286
using assms by(induction xs ys rule: wpull_induct) auto
Andreas@62139
   287
Andreas@62139
   288
qualified lemma set_fst_wpull:
Andreas@62139
   289
  assumes "remdups (map snd xs) = remdups (map fst ys)"
Andreas@62139
   290
  shows "fst ` set (wpull xs ys) = fst ` set xs"
Andreas@62139
   291
using assms by(induction xs ys rule: wpull_induct)(auto intro: rev_image_eqI)
Andreas@62139
   292
Andreas@62139
   293
qualified lemma set_snd_wpull:
Andreas@62139
   294
  assumes "remdups (map snd xs) = remdups (map fst ys)"
Andreas@62139
   295
  shows "snd ` set (wpull xs ys) = snd ` set ys"
Andreas@62139
   296
using assms by(induction xs ys rule: wpull_induct)(auto intro: rev_image_eqI)
Andreas@62139
   297
  
Andreas@62139
   298
qualified lemma wpull:
Andreas@62139
   299
  assumes "distinct xs"
Andreas@62139
   300
  and "distinct ys"
Andreas@62139
   301
  and "set xs \<subseteq> {(x, y). R x y}"
Andreas@62139
   302
  and "set ys \<subseteq> {(x, y). S x y}"
Andreas@62139
   303
  and eq: "remdups (map snd xs) = remdups (map fst ys)"
Andreas@62139
   304
  shows "\<exists>zs. distinct zs \<and> set zs \<subseteq> {(x, y). (R OO S) x y} \<and>
Andreas@62139
   305
         remdups (map fst zs) = remdups (map fst xs) \<and> remdups (map snd zs) = remdups (map snd ys)"
Andreas@62139
   306
proof(intro exI conjI)
Andreas@62139
   307
  let ?zs = "remdups (wpull xs ys)"
Andreas@62139
   308
  show "distinct ?zs" by simp
Andreas@62139
   309
  show "set ?zs \<subseteq> {(x, y). (R OO S) x y}" using assms(3-4) set_wpull_subset[OF eq] by fastforce
Andreas@62139
   310
  show "remdups (map fst ?zs) = remdups (map fst xs)" unfolding remdups_map_remdups using eq
Andreas@62139
   311
    by(induction xs ys rule: wpull_induct)(auto simp add: set_fst_wpull intro: rev_image_eqI)
Andreas@62139
   312
  show "remdups (map snd ?zs) = remdups (map snd ys)" unfolding remdups_map_remdups using eq
Andreas@62139
   313
    by(induction xs ys rule: wpull_induct)(auto simp add: set_snd_wpull intro: rev_image_eqI)
Andreas@62139
   314
qed
Andreas@62139
   315
Andreas@62139
   316
qualified lift_definition set :: "'a dlist \<Rightarrow> 'a set" is List.set .
Andreas@62139
   317
Andreas@62139
   318
qualified lemma map_transfer [transfer_rule]:
nipkow@67399
   319
  "(rel_fun (=) (rel_fun (pcr_dlist (=)) (pcr_dlist (=)))) (\<lambda>f x. remdups (List.map f x)) Dlist.map"
Andreas@62139
   320
by(simp add: rel_fun_def dlist.pcr_cr_eq cr_dlist_def Dlist.map_def remdups_remdups)
Andreas@62139
   321
Andreas@62139
   322
bnf "'a dlist"
Andreas@62139
   323
  map: Dlist.map
Andreas@62139
   324
  sets: set
Andreas@62139
   325
  bd: natLeq
Andreas@62139
   326
  wits: Dlist.empty
Andreas@62139
   327
unfolding OO_Grp_alt mem_Collect_eq
Andreas@62139
   328
subgoal by(rule ext)(simp add: dlist_eq_iff)
Andreas@62139
   329
subgoal by(rule ext)(simp add: dlist_eq_iff remdups_map_remdups)
Andreas@62139
   330
subgoal by(simp add: dlist_eq_iff set_def cong: list.map_cong)
Andreas@62139
   331
subgoal by(simp add: set_def fun_eq_iff)
Andreas@62139
   332
subgoal by(simp add: natLeq_card_order)
Andreas@62139
   333
subgoal by(simp add: natLeq_cinfinite)
Andreas@62139
   334
subgoal by(rule ordLess_imp_ordLeq)(simp add: finite_iff_ordLess_natLeq[symmetric] set_def)
Andreas@62139
   335
subgoal by(rule predicate2I)(transfer; auto simp add: wpull)
Andreas@62139
   336
subgoal by(simp add: set_def)
Andreas@62139
   337
done
Andreas@62139
   338
Andreas@62139
   339
lifting_update dlist.lifting
Andreas@62139
   340
lifting_forget dlist.lifting
Andreas@62139
   341
haftmann@35303
   342
end
Andreas@62139
   343
nipkow@62390
   344
end