src/HOL/Library/Quotient_List.thy
author huffman
Mon May 14 17:28:07 2012 +0200 (2012-05-14)
changeset 47923 ba9df9685e7c
parent 47777 f29e7dcd7c40
child 47929 3465c09222e0
permissions -rw-r--r--
add transfer rule for constant List.lists
wenzelm@47455
     1
(*  Title:      HOL/Library/Quotient_List.thy
huffman@47641
     2
    Author:     Cezary Kaliszyk, Christian Urban and Brian Huffman
kaliszyk@35222
     3
*)
wenzelm@35788
     4
wenzelm@35788
     5
header {* Quotient infrastructure for the list type *}
wenzelm@35788
     6
kaliszyk@35222
     7
theory Quotient_List
huffman@47650
     8
imports Main Quotient_Set
kaliszyk@35222
     9
begin
kaliszyk@35222
    10
huffman@47641
    11
subsection {* Relator for list type *}
huffman@47641
    12
haftmann@40820
    13
lemma map_id [id_simps]:
haftmann@40820
    14
  "map id = id"
haftmann@46663
    15
  by (fact List.map.id)
kaliszyk@35222
    16
huffman@47641
    17
lemma list_all2_eq [id_simps, relator_eq]:
haftmann@40820
    18
  "list_all2 (op =) = (op =)"
haftmann@40820
    19
proof (rule ext)+
haftmann@40820
    20
  fix xs ys
haftmann@40820
    21
  show "list_all2 (op =) xs ys \<longleftrightarrow> xs = ys"
haftmann@40820
    22
    by (induct xs ys rule: list_induct2') simp_all
haftmann@40820
    23
qed
kaliszyk@35222
    24
huffman@47660
    25
lemma list_all2_OO: "list_all2 (A OO B) = list_all2 A OO list_all2 B"
huffman@47660
    26
proof (intro ext iffI)
huffman@47660
    27
  fix xs ys
huffman@47660
    28
  assume "list_all2 (A OO B) xs ys"
huffman@47660
    29
  thus "(list_all2 A OO list_all2 B) xs ys"
huffman@47660
    30
    unfolding OO_def
huffman@47660
    31
    by (induct, simp, simp add: list_all2_Cons1 list_all2_Cons2, fast)
huffman@47660
    32
next
huffman@47660
    33
  fix xs ys
huffman@47660
    34
  assume "(list_all2 A OO list_all2 B) xs ys"
huffman@47660
    35
  then obtain zs where "list_all2 A xs zs" and "list_all2 B zs ys" ..
huffman@47660
    36
  thus "list_all2 (A OO B) xs ys"
huffman@47660
    37
    by (induct arbitrary: ys, simp, clarsimp simp add: list_all2_Cons1, fast)
huffman@47660
    38
qed
huffman@47660
    39
haftmann@40820
    40
lemma list_reflp:
haftmann@40820
    41
  assumes "reflp R"
haftmann@40820
    42
  shows "reflp (list_all2 R)"
haftmann@40820
    43
proof (rule reflpI)
haftmann@40820
    44
  from assms have *: "\<And>xs. R xs xs" by (rule reflpE)
haftmann@40820
    45
  fix xs
haftmann@40820
    46
  show "list_all2 R xs xs"
haftmann@40820
    47
    by (induct xs) (simp_all add: *)
haftmann@40820
    48
qed
kaliszyk@35222
    49
haftmann@40820
    50
lemma list_symp:
haftmann@40820
    51
  assumes "symp R"
haftmann@40820
    52
  shows "symp (list_all2 R)"
haftmann@40820
    53
proof (rule sympI)
haftmann@40820
    54
  from assms have *: "\<And>xs ys. R xs ys \<Longrightarrow> R ys xs" by (rule sympE)
haftmann@40820
    55
  fix xs ys
haftmann@40820
    56
  assume "list_all2 R xs ys"
haftmann@40820
    57
  then show "list_all2 R ys xs"
haftmann@40820
    58
    by (induct xs ys rule: list_induct2') (simp_all add: *)
haftmann@40820
    59
qed
kaliszyk@35222
    60
haftmann@40820
    61
lemma list_transp:
haftmann@40820
    62
  assumes "transp R"
haftmann@40820
    63
  shows "transp (list_all2 R)"
haftmann@40820
    64
proof (rule transpI)
haftmann@40820
    65
  from assms have *: "\<And>xs ys zs. R xs ys \<Longrightarrow> R ys zs \<Longrightarrow> R xs zs" by (rule transpE)
haftmann@40820
    66
  fix xs ys zs
huffman@45803
    67
  assume "list_all2 R xs ys" and "list_all2 R ys zs"
huffman@45803
    68
  then show "list_all2 R xs zs"
huffman@45803
    69
    by (induct arbitrary: zs) (auto simp: list_all2_Cons1 intro: *)
haftmann@40820
    70
qed
kaliszyk@35222
    71
haftmann@40820
    72
lemma list_equivp [quot_equiv]:
haftmann@40820
    73
  "equivp R \<Longrightarrow> equivp (list_all2 R)"
haftmann@40820
    74
  by (blast intro: equivpI list_reflp list_symp list_transp elim: equivpE)
kaliszyk@35222
    75
huffman@47641
    76
lemma right_total_list_all2 [transfer_rule]:
huffman@47641
    77
  "right_total R \<Longrightarrow> right_total (list_all2 R)"
huffman@47641
    78
  unfolding right_total_def
huffman@47641
    79
  by (rule allI, induct_tac y, simp, simp add: list_all2_Cons2)
huffman@47641
    80
huffman@47641
    81
lemma right_unique_list_all2 [transfer_rule]:
huffman@47641
    82
  "right_unique R \<Longrightarrow> right_unique (list_all2 R)"
huffman@47641
    83
  unfolding right_unique_def
huffman@47641
    84
  apply (rule allI, rename_tac xs, induct_tac xs)
huffman@47641
    85
  apply (auto simp add: list_all2_Cons1)
huffman@47641
    86
  done
huffman@47641
    87
huffman@47641
    88
lemma bi_total_list_all2 [transfer_rule]:
huffman@47641
    89
  "bi_total A \<Longrightarrow> bi_total (list_all2 A)"
huffman@47641
    90
  unfolding bi_total_def
huffman@47641
    91
  apply safe
huffman@47641
    92
  apply (rename_tac xs, induct_tac xs, simp, simp add: list_all2_Cons1)
huffman@47641
    93
  apply (rename_tac ys, induct_tac ys, simp, simp add: list_all2_Cons2)
huffman@47641
    94
  done
huffman@47641
    95
huffman@47641
    96
lemma bi_unique_list_all2 [transfer_rule]:
huffman@47641
    97
  "bi_unique A \<Longrightarrow> bi_unique (list_all2 A)"
huffman@47641
    98
  unfolding bi_unique_def
huffman@47641
    99
  apply (rule conjI)
huffman@47641
   100
  apply (rule allI, rename_tac xs, induct_tac xs)
huffman@47641
   101
  apply (simp, force simp add: list_all2_Cons1)
huffman@47641
   102
  apply (subst (2) all_comm, subst (1) all_comm)
huffman@47641
   103
  apply (rule allI, rename_tac xs, induct_tac xs)
huffman@47641
   104
  apply (simp, force simp add: list_all2_Cons2)
huffman@47641
   105
  done
huffman@47641
   106
huffman@47641
   107
subsection {* Transfer rules for transfer package *}
huffman@47641
   108
huffman@47641
   109
lemma Nil_transfer [transfer_rule]: "(list_all2 A) [] []"
huffman@47641
   110
  by simp
huffman@47641
   111
huffman@47641
   112
lemma Cons_transfer [transfer_rule]:
huffman@47641
   113
  "(A ===> list_all2 A ===> list_all2 A) Cons Cons"
huffman@47641
   114
  unfolding fun_rel_def by simp
huffman@47641
   115
huffman@47641
   116
lemma list_case_transfer [transfer_rule]:
huffman@47641
   117
  "(B ===> (A ===> list_all2 A ===> B) ===> list_all2 A ===> B)
huffman@47641
   118
    list_case list_case"
huffman@47641
   119
  unfolding fun_rel_def by (simp split: list.split)
huffman@47641
   120
huffman@47641
   121
lemma list_rec_transfer [transfer_rule]:
huffman@47641
   122
  "(B ===> (A ===> list_all2 A ===> B ===> B) ===> list_all2 A ===> B)
huffman@47641
   123
    list_rec list_rec"
huffman@47641
   124
  unfolding fun_rel_def by (clarify, erule list_all2_induct, simp_all)
huffman@47641
   125
huffman@47641
   126
lemma map_transfer [transfer_rule]:
huffman@47641
   127
  "((A ===> B) ===> list_all2 A ===> list_all2 B) map map"
huffman@47641
   128
  unfolding List.map_def by transfer_prover
huffman@47641
   129
huffman@47641
   130
lemma append_transfer [transfer_rule]:
huffman@47641
   131
  "(list_all2 A ===> list_all2 A ===> list_all2 A) append append"
huffman@47641
   132
  unfolding List.append_def by transfer_prover
huffman@47641
   133
huffman@47641
   134
lemma filter_transfer [transfer_rule]:
huffman@47641
   135
  "((A ===> op =) ===> list_all2 A ===> list_all2 A) filter filter"
huffman@47641
   136
  unfolding List.filter_def by transfer_prover
huffman@47641
   137
huffman@47641
   138
lemma foldr_transfer [transfer_rule]:
huffman@47641
   139
  "((A ===> B ===> B) ===> list_all2 A ===> B ===> B) foldr foldr"
huffman@47641
   140
  unfolding List.foldr_def by transfer_prover
huffman@47641
   141
huffman@47641
   142
lemma foldl_transfer [transfer_rule]:
huffman@47641
   143
  "((B ===> A ===> B) ===> B ===> list_all2 A ===> B) foldl foldl"
huffman@47641
   144
  unfolding List.foldl_def by transfer_prover
huffman@47641
   145
huffman@47641
   146
lemma concat_transfer [transfer_rule]:
huffman@47641
   147
  "(list_all2 (list_all2 A) ===> list_all2 A) concat concat"
huffman@47641
   148
  unfolding List.concat_def by transfer_prover
huffman@47641
   149
huffman@47641
   150
lemma drop_transfer [transfer_rule]:
huffman@47641
   151
  "(op = ===> list_all2 A ===> list_all2 A) drop drop"
huffman@47641
   152
  unfolding List.drop_def by transfer_prover
huffman@47641
   153
huffman@47641
   154
lemma take_transfer [transfer_rule]:
huffman@47641
   155
  "(op = ===> list_all2 A ===> list_all2 A) take take"
huffman@47641
   156
  unfolding List.take_def by transfer_prover
huffman@47641
   157
huffman@47641
   158
lemma length_transfer [transfer_rule]:
huffman@47641
   159
  "(list_all2 A ===> op =) length length"
huffman@47641
   160
  unfolding list_size_overloaded_def by transfer_prover
huffman@47641
   161
huffman@47641
   162
lemma list_all_transfer [transfer_rule]:
huffman@47641
   163
  "((A ===> op =) ===> list_all2 A ===> op =) list_all list_all"
huffman@47641
   164
  unfolding fun_rel_def by (clarify, erule list_all2_induct, simp_all)
huffman@47641
   165
huffman@47641
   166
lemma list_all2_transfer [transfer_rule]:
huffman@47641
   167
  "((A ===> B ===> op =) ===> list_all2 A ===> list_all2 B ===> op =)
huffman@47641
   168
    list_all2 list_all2"
huffman@47641
   169
  apply (rule fun_relI, rule fun_relI, erule list_all2_induct)
huffman@47641
   170
  apply (rule fun_relI, erule list_all2_induct, simp, simp)
huffman@47641
   171
  apply (rule fun_relI, erule list_all2_induct [of B])
huffman@47641
   172
  apply (simp, simp add: fun_rel_def)
huffman@47641
   173
  done
huffman@47641
   174
huffman@47650
   175
lemma set_transfer [transfer_rule]:
huffman@47650
   176
  "(list_all2 A ===> set_rel A) set set"
huffman@47650
   177
  unfolding set_def by transfer_prover
huffman@47650
   178
huffman@47923
   179
lemma lists_transfer [transfer_rule]:
huffman@47923
   180
  "(set_rel A ===> set_rel (list_all2 A)) lists lists"
huffman@47923
   181
  apply (rule fun_relI, rule set_relI)
huffman@47923
   182
  apply (erule lists.induct, simp)
huffman@47923
   183
  apply (simp only: set_rel_def list_all2_Cons1, metis lists.Cons)
huffman@47923
   184
  apply (erule lists.induct, simp)
huffman@47923
   185
  apply (simp only: set_rel_def list_all2_Cons2, metis lists.Cons)
huffman@47923
   186
  done
huffman@47923
   187
huffman@47641
   188
subsection {* Setup for lifting package *}
huffman@47641
   189
kuncar@47777
   190
lemma Quotient_list[quot_map]:
huffman@47641
   191
  assumes "Quotient R Abs Rep T"
huffman@47641
   192
  shows "Quotient (list_all2 R) (map Abs) (map Rep) (list_all2 T)"
huffman@47641
   193
proof (unfold Quotient_alt_def, intro conjI allI impI)
huffman@47641
   194
  from assms have 1: "\<And>x y. T x y \<Longrightarrow> Abs x = y"
huffman@47641
   195
    unfolding Quotient_alt_def by simp
huffman@47641
   196
  fix xs ys assume "list_all2 T xs ys" thus "map Abs xs = ys"
huffman@47641
   197
    by (induct, simp, simp add: 1)
huffman@47641
   198
next
huffman@47641
   199
  from assms have 2: "\<And>x. T (Rep x) x"
huffman@47641
   200
    unfolding Quotient_alt_def by simp
huffman@47641
   201
  fix xs show "list_all2 T (map Rep xs) xs"
huffman@47641
   202
    by (induct xs, simp, simp add: 2)
huffman@47641
   203
next
huffman@47641
   204
  from assms have 3: "\<And>x y. R x y \<longleftrightarrow> T x (Abs x) \<and> T y (Abs y) \<and> Abs x = Abs y"
huffman@47641
   205
    unfolding Quotient_alt_def by simp
huffman@47641
   206
  fix xs ys show "list_all2 R xs ys \<longleftrightarrow> list_all2 T xs (map Abs xs) \<and>
huffman@47641
   207
    list_all2 T ys (map Abs ys) \<and> map Abs xs = map Abs ys"
huffman@47641
   208
    by (induct xs ys rule: list_induct2', simp_all, metis 3)
huffman@47641
   209
qed
huffman@47641
   210
huffman@47641
   211
lemma list_invariant_commute [invariant_commute]:
huffman@47641
   212
  "list_all2 (Lifting.invariant P) = Lifting.invariant (list_all P)"
huffman@47641
   213
  apply (simp add: fun_eq_iff list_all2_def list_all_iff Lifting.invariant_def Ball_def) 
huffman@47641
   214
  apply (intro allI) 
huffman@47641
   215
  apply (induct_tac rule: list_induct2') 
huffman@47641
   216
  apply simp_all 
huffman@47641
   217
  apply metis
huffman@47641
   218
done
huffman@47641
   219
huffman@47641
   220
subsection {* Rules for quotient package *}
huffman@47641
   221
kuncar@47308
   222
lemma list_quotient3 [quot_thm]:
kuncar@47308
   223
  assumes "Quotient3 R Abs Rep"
kuncar@47308
   224
  shows "Quotient3 (list_all2 R) (map Abs) (map Rep)"
kuncar@47308
   225
proof (rule Quotient3I)
kuncar@47308
   226
  from assms have "\<And>x. Abs (Rep x) = x" by (rule Quotient3_abs_rep)
haftmann@40820
   227
  then show "\<And>xs. map Abs (map Rep xs) = xs" by (simp add: comp_def)
haftmann@40820
   228
next
kuncar@47308
   229
  from assms have "\<And>x y. R (Rep x) (Rep y) \<longleftrightarrow> x = y" by (rule Quotient3_rel_rep)
haftmann@40820
   230
  then show "\<And>xs. list_all2 R (map Rep xs) (map Rep xs)"
haftmann@40820
   231
    by (simp add: list_all2_map1 list_all2_map2 list_all2_eq)
haftmann@40820
   232
next
haftmann@40820
   233
  fix xs ys
kuncar@47308
   234
  from assms have "\<And>x y. R x x \<and> R y y \<and> Abs x = Abs y \<longleftrightarrow> R x y" by (rule Quotient3_rel)
haftmann@40820
   235
  then show "list_all2 R xs ys \<longleftrightarrow> list_all2 R xs xs \<and> list_all2 R ys ys \<and> map Abs xs = map Abs ys"
haftmann@40820
   236
    by (induct xs ys rule: list_induct2') auto
haftmann@40820
   237
qed
kaliszyk@35222
   238
kuncar@47308
   239
declare [[mapQ3 list = (list_all2, list_quotient3)]]
kuncar@47094
   240
haftmann@40820
   241
lemma cons_prs [quot_preserve]:
kuncar@47308
   242
  assumes q: "Quotient3 R Abs Rep"
kaliszyk@35222
   243
  shows "(Rep ---> (map Rep) ---> (map Abs)) (op #) = (op #)"
kuncar@47308
   244
  by (auto simp add: fun_eq_iff comp_def Quotient3_abs_rep [OF q])
kaliszyk@35222
   245
haftmann@40820
   246
lemma cons_rsp [quot_respect]:
kuncar@47308
   247
  assumes q: "Quotient3 R Abs Rep"
kaliszyk@37492
   248
  shows "(R ===> list_all2 R ===> list_all2 R) (op #) (op #)"
haftmann@40463
   249
  by auto
kaliszyk@35222
   250
haftmann@40820
   251
lemma nil_prs [quot_preserve]:
kuncar@47308
   252
  assumes q: "Quotient3 R Abs Rep"
kaliszyk@35222
   253
  shows "map Abs [] = []"
kaliszyk@35222
   254
  by simp
kaliszyk@35222
   255
haftmann@40820
   256
lemma nil_rsp [quot_respect]:
kuncar@47308
   257
  assumes q: "Quotient3 R Abs Rep"
kaliszyk@37492
   258
  shows "list_all2 R [] []"
kaliszyk@35222
   259
  by simp
kaliszyk@35222
   260
kaliszyk@35222
   261
lemma map_prs_aux:
kuncar@47308
   262
  assumes a: "Quotient3 R1 abs1 rep1"
kuncar@47308
   263
  and     b: "Quotient3 R2 abs2 rep2"
kaliszyk@35222
   264
  shows "(map abs2) (map ((abs1 ---> rep2) f) (map rep1 l)) = map f l"
kaliszyk@35222
   265
  by (induct l)
kuncar@47308
   266
     (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
kaliszyk@35222
   267
haftmann@40820
   268
lemma map_prs [quot_preserve]:
kuncar@47308
   269
  assumes a: "Quotient3 R1 abs1 rep1"
kuncar@47308
   270
  and     b: "Quotient3 R2 abs2 rep2"
kaliszyk@35222
   271
  shows "((abs1 ---> rep2) ---> (map rep1) ---> (map abs2)) map = map"
kaliszyk@36216
   272
  and   "((abs1 ---> id) ---> map rep1 ---> id) map = map"
haftmann@40463
   273
  by (simp_all only: fun_eq_iff map_prs_aux[OF a b] comp_def)
kuncar@47308
   274
    (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
haftmann@40463
   275
haftmann@40820
   276
lemma map_rsp [quot_respect]:
kuncar@47308
   277
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
   278
  and     q2: "Quotient3 R2 Abs2 Rep2"
kaliszyk@37492
   279
  shows "((R1 ===> R2) ===> (list_all2 R1) ===> list_all2 R2) map map"
kaliszyk@37492
   280
  and   "((R1 ===> op =) ===> (list_all2 R1) ===> op =) map map"
huffman@47641
   281
  unfolding list_all2_eq [symmetric] by (rule map_transfer)+
kaliszyk@35222
   282
kaliszyk@35222
   283
lemma foldr_prs_aux:
kuncar@47308
   284
  assumes a: "Quotient3 R1 abs1 rep1"
kuncar@47308
   285
  and     b: "Quotient3 R2 abs2 rep2"
kaliszyk@35222
   286
  shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e"
kuncar@47308
   287
  by (induct l) (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
kaliszyk@35222
   288
haftmann@40820
   289
lemma foldr_prs [quot_preserve]:
kuncar@47308
   290
  assumes a: "Quotient3 R1 abs1 rep1"
kuncar@47308
   291
  and     b: "Quotient3 R2 abs2 rep2"
kaliszyk@35222
   292
  shows "((abs1 ---> abs2 ---> rep2) ---> (map rep1) ---> rep2 ---> abs2) foldr = foldr"
haftmann@40463
   293
  apply (simp add: fun_eq_iff)
haftmann@40463
   294
  by (simp only: fun_eq_iff foldr_prs_aux[OF a b])
kaliszyk@35222
   295
     (simp)
kaliszyk@35222
   296
kaliszyk@35222
   297
lemma foldl_prs_aux:
kuncar@47308
   298
  assumes a: "Quotient3 R1 abs1 rep1"
kuncar@47308
   299
  and     b: "Quotient3 R2 abs2 rep2"
kaliszyk@35222
   300
  shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l"
kuncar@47308
   301
  by (induct l arbitrary:e) (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
kaliszyk@35222
   302
haftmann@40820
   303
lemma foldl_prs [quot_preserve]:
kuncar@47308
   304
  assumes a: "Quotient3 R1 abs1 rep1"
kuncar@47308
   305
  and     b: "Quotient3 R2 abs2 rep2"
kaliszyk@35222
   306
  shows "((abs1 ---> abs2 ---> rep1) ---> rep1 ---> (map rep2) ---> abs1) foldl = foldl"
haftmann@40463
   307
  by (simp add: fun_eq_iff foldl_prs_aux [OF a b])
kaliszyk@35222
   308
kaliszyk@35222
   309
(* induct_tac doesn't accept 'arbitrary', so we manually 'spec' *)
kaliszyk@35222
   310
lemma foldl_rsp[quot_respect]:
kuncar@47308
   311
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
   312
  and     q2: "Quotient3 R2 Abs2 Rep2"
kaliszyk@37492
   313
  shows "((R1 ===> R2 ===> R1) ===> R1 ===> list_all2 R2 ===> R1) foldl foldl"
huffman@47641
   314
  by (rule foldl_transfer)
kaliszyk@35222
   315
kaliszyk@35222
   316
lemma foldr_rsp[quot_respect]:
kuncar@47308
   317
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
   318
  and     q2: "Quotient3 R2 Abs2 Rep2"
kaliszyk@37492
   319
  shows "((R1 ===> R2 ===> R2) ===> list_all2 R1 ===> R2 ===> R2) foldr foldr"
huffman@47641
   320
  by (rule foldr_transfer)
kaliszyk@35222
   321
kaliszyk@37492
   322
lemma list_all2_rsp:
kaliszyk@36154
   323
  assumes r: "\<forall>x y. R x y \<longrightarrow> (\<forall>a b. R a b \<longrightarrow> S x a = T y b)"
kaliszyk@37492
   324
  and l1: "list_all2 R x y"
kaliszyk@37492
   325
  and l2: "list_all2 R a b"
kaliszyk@37492
   326
  shows "list_all2 S x a = list_all2 T y b"
huffman@45803
   327
  using l1 l2
huffman@45803
   328
  by (induct arbitrary: a b rule: list_all2_induct,
huffman@45803
   329
    auto simp: list_all2_Cons1 list_all2_Cons2 r)
kaliszyk@36154
   330
haftmann@40820
   331
lemma [quot_respect]:
kaliszyk@37492
   332
  "((R ===> R ===> op =) ===> list_all2 R ===> list_all2 R ===> op =) list_all2 list_all2"
huffman@47641
   333
  by (rule list_all2_transfer)
kaliszyk@36154
   334
haftmann@40820
   335
lemma [quot_preserve]:
kuncar@47308
   336
  assumes a: "Quotient3 R abs1 rep1"
kaliszyk@37492
   337
  shows "((abs1 ---> abs1 ---> id) ---> map rep1 ---> map rep1 ---> id) list_all2 = list_all2"
nipkow@39302
   338
  apply (simp add: fun_eq_iff)
kaliszyk@36154
   339
  apply clarify
kaliszyk@36154
   340
  apply (induct_tac xa xb rule: list_induct2')
kuncar@47308
   341
  apply (simp_all add: Quotient3_abs_rep[OF a])
kaliszyk@36154
   342
  done
kaliszyk@36154
   343
haftmann@40820
   344
lemma [quot_preserve]:
kuncar@47308
   345
  assumes a: "Quotient3 R abs1 rep1"
kaliszyk@37492
   346
  shows "(list_all2 ((rep1 ---> rep1 ---> id) R) l m) = (l = m)"
kuncar@47308
   347
  by (induct l m rule: list_induct2') (simp_all add: Quotient3_rel_rep[OF a])
kaliszyk@36154
   348
kaliszyk@37492
   349
lemma list_all2_find_element:
kaliszyk@36276
   350
  assumes a: "x \<in> set a"
kaliszyk@37492
   351
  and b: "list_all2 R a b"
kaliszyk@36276
   352
  shows "\<exists>y. (y \<in> set b \<and> R x y)"
huffman@45803
   353
  using b a by induct auto
kaliszyk@36276
   354
kaliszyk@37492
   355
lemma list_all2_refl:
kaliszyk@35222
   356
  assumes a: "\<And>x y. R x y = (R x = R y)"
kaliszyk@37492
   357
  shows "list_all2 R x x"
kaliszyk@35222
   358
  by (induct x) (auto simp add: a)
kaliszyk@35222
   359
kaliszyk@35222
   360
end