src/HOL/Library/Quotient_List.thy
author Andreas Lochbihler
Wed Feb 27 10:33:30 2013 +0100 (2013-02-27)
changeset 51288 be7e9a675ec9
parent 47982 7aa35601ff65
child 51377 7da251a6c16e
permissions -rw-r--r--
add wellorder instance for Numeral_Type (suggested by Jesus Aransay)
     1 (*  Title:      HOL/Library/Quotient_List.thy
     2     Author:     Cezary Kaliszyk, Christian Urban and Brian Huffman
     3 *)
     4 
     5 header {* Quotient infrastructure for the list type *}
     6 
     7 theory Quotient_List
     8 imports Main Quotient_Set Quotient_Product Quotient_Option
     9 begin
    10 
    11 subsection {* Relator for list type *}
    12 
    13 lemma map_id [id_simps]:
    14   "map id = id"
    15   by (fact List.map.id)
    16 
    17 lemma list_all2_eq [id_simps, relator_eq]:
    18   "list_all2 (op =) = (op =)"
    19 proof (rule ext)+
    20   fix xs ys
    21   show "list_all2 (op =) xs ys \<longleftrightarrow> xs = ys"
    22     by (induct xs ys rule: list_induct2') simp_all
    23 qed
    24 
    25 lemma list_all2_OO: "list_all2 (A OO B) = list_all2 A OO list_all2 B"
    26 proof (intro ext iffI)
    27   fix xs ys
    28   assume "list_all2 (A OO B) xs ys"
    29   thus "(list_all2 A OO list_all2 B) xs ys"
    30     unfolding OO_def
    31     by (induct, simp, simp add: list_all2_Cons1 list_all2_Cons2, fast)
    32 next
    33   fix xs ys
    34   assume "(list_all2 A OO list_all2 B) xs ys"
    35   then obtain zs where "list_all2 A xs zs" and "list_all2 B zs ys" ..
    36   thus "list_all2 (A OO B) xs ys"
    37     by (induct arbitrary: ys, simp, clarsimp simp add: list_all2_Cons1, fast)
    38 qed
    39 
    40 lemma list_reflp[reflexivity_rule]:
    41   assumes "reflp R"
    42   shows "reflp (list_all2 R)"
    43 proof (rule reflpI)
    44   from assms have *: "\<And>xs. R xs xs" by (rule reflpE)
    45   fix xs
    46   show "list_all2 R xs xs"
    47     by (induct xs) (simp_all add: *)
    48 qed
    49 
    50 lemma list_left_total[reflexivity_rule]:
    51   assumes "left_total R"
    52   shows "left_total (list_all2 R)"
    53 proof (rule left_totalI)
    54   from assms have *: "\<And>xs. \<exists>ys. R xs ys" by (rule left_totalE)
    55   fix xs
    56   show "\<exists> ys. list_all2 R xs ys"
    57     by (induct xs) (simp_all add: * list_all2_Cons1)
    58 qed
    59 
    60 
    61 lemma list_symp:
    62   assumes "symp R"
    63   shows "symp (list_all2 R)"
    64 proof (rule sympI)
    65   from assms have *: "\<And>xs ys. R xs ys \<Longrightarrow> R ys xs" by (rule sympE)
    66   fix xs ys
    67   assume "list_all2 R xs ys"
    68   then show "list_all2 R ys xs"
    69     by (induct xs ys rule: list_induct2') (simp_all add: *)
    70 qed
    71 
    72 lemma list_transp:
    73   assumes "transp R"
    74   shows "transp (list_all2 R)"
    75 proof (rule transpI)
    76   from assms have *: "\<And>xs ys zs. R xs ys \<Longrightarrow> R ys zs \<Longrightarrow> R xs zs" by (rule transpE)
    77   fix xs ys zs
    78   assume "list_all2 R xs ys" and "list_all2 R ys zs"
    79   then show "list_all2 R xs zs"
    80     by (induct arbitrary: zs) (auto simp: list_all2_Cons1 intro: *)
    81 qed
    82 
    83 lemma list_equivp [quot_equiv]:
    84   "equivp R \<Longrightarrow> equivp (list_all2 R)"
    85   by (blast intro: equivpI list_reflp list_symp list_transp elim: equivpE)
    86 
    87 lemma right_total_list_all2 [transfer_rule]:
    88   "right_total R \<Longrightarrow> right_total (list_all2 R)"
    89   unfolding right_total_def
    90   by (rule allI, induct_tac y, simp, simp add: list_all2_Cons2)
    91 
    92 lemma right_unique_list_all2 [transfer_rule]:
    93   "right_unique R \<Longrightarrow> right_unique (list_all2 R)"
    94   unfolding right_unique_def
    95   apply (rule allI, rename_tac xs, induct_tac xs)
    96   apply (auto simp add: list_all2_Cons1)
    97   done
    98 
    99 lemma bi_total_list_all2 [transfer_rule]:
   100   "bi_total A \<Longrightarrow> bi_total (list_all2 A)"
   101   unfolding bi_total_def
   102   apply safe
   103   apply (rename_tac xs, induct_tac xs, simp, simp add: list_all2_Cons1)
   104   apply (rename_tac ys, induct_tac ys, simp, simp add: list_all2_Cons2)
   105   done
   106 
   107 lemma bi_unique_list_all2 [transfer_rule]:
   108   "bi_unique A \<Longrightarrow> bi_unique (list_all2 A)"
   109   unfolding bi_unique_def
   110   apply (rule conjI)
   111   apply (rule allI, rename_tac xs, induct_tac xs)
   112   apply (simp, force simp add: list_all2_Cons1)
   113   apply (subst (2) all_comm, subst (1) all_comm)
   114   apply (rule allI, rename_tac xs, induct_tac xs)
   115   apply (simp, force simp add: list_all2_Cons2)
   116   done
   117 
   118 subsection {* Transfer rules for transfer package *}
   119 
   120 lemma Nil_transfer [transfer_rule]: "(list_all2 A) [] []"
   121   by simp
   122 
   123 lemma Cons_transfer [transfer_rule]:
   124   "(A ===> list_all2 A ===> list_all2 A) Cons Cons"
   125   unfolding fun_rel_def by simp
   126 
   127 lemma list_case_transfer [transfer_rule]:
   128   "(B ===> (A ===> list_all2 A ===> B) ===> list_all2 A ===> B)
   129     list_case list_case"
   130   unfolding fun_rel_def by (simp split: list.split)
   131 
   132 lemma list_rec_transfer [transfer_rule]:
   133   "(B ===> (A ===> list_all2 A ===> B ===> B) ===> list_all2 A ===> B)
   134     list_rec list_rec"
   135   unfolding fun_rel_def by (clarify, erule list_all2_induct, simp_all)
   136 
   137 lemma tl_transfer [transfer_rule]:
   138   "(list_all2 A ===> list_all2 A) tl tl"
   139   unfolding tl_def by transfer_prover
   140 
   141 lemma butlast_transfer [transfer_rule]:
   142   "(list_all2 A ===> list_all2 A) butlast butlast"
   143   by (rule fun_relI, erule list_all2_induct, auto)
   144 
   145 lemma set_transfer [transfer_rule]:
   146   "(list_all2 A ===> set_rel A) set set"
   147   unfolding set_def by transfer_prover
   148 
   149 lemma map_transfer [transfer_rule]:
   150   "((A ===> B) ===> list_all2 A ===> list_all2 B) map map"
   151   unfolding List.map_def by transfer_prover
   152 
   153 lemma append_transfer [transfer_rule]:
   154   "(list_all2 A ===> list_all2 A ===> list_all2 A) append append"
   155   unfolding List.append_def by transfer_prover
   156 
   157 lemma rev_transfer [transfer_rule]:
   158   "(list_all2 A ===> list_all2 A) rev rev"
   159   unfolding List.rev_def by transfer_prover
   160 
   161 lemma filter_transfer [transfer_rule]:
   162   "((A ===> op =) ===> list_all2 A ===> list_all2 A) filter filter"
   163   unfolding List.filter_def by transfer_prover
   164 
   165 lemma fold_transfer [transfer_rule]:
   166   "((A ===> B ===> B) ===> list_all2 A ===> B ===> B) fold fold"
   167   unfolding List.fold_def by transfer_prover
   168 
   169 lemma foldr_transfer [transfer_rule]:
   170   "((A ===> B ===> B) ===> list_all2 A ===> B ===> B) foldr foldr"
   171   unfolding List.foldr_def by transfer_prover
   172 
   173 lemma foldl_transfer [transfer_rule]:
   174   "((B ===> A ===> B) ===> B ===> list_all2 A ===> B) foldl foldl"
   175   unfolding List.foldl_def by transfer_prover
   176 
   177 lemma concat_transfer [transfer_rule]:
   178   "(list_all2 (list_all2 A) ===> list_all2 A) concat concat"
   179   unfolding List.concat_def by transfer_prover
   180 
   181 lemma drop_transfer [transfer_rule]:
   182   "(op = ===> list_all2 A ===> list_all2 A) drop drop"
   183   unfolding List.drop_def by transfer_prover
   184 
   185 lemma take_transfer [transfer_rule]:
   186   "(op = ===> list_all2 A ===> list_all2 A) take take"
   187   unfolding List.take_def by transfer_prover
   188 
   189 lemma list_update_transfer [transfer_rule]:
   190   "(list_all2 A ===> op = ===> A ===> list_all2 A) list_update list_update"
   191   unfolding list_update_def by transfer_prover
   192 
   193 lemma takeWhile_transfer [transfer_rule]:
   194   "((A ===> op =) ===> list_all2 A ===> list_all2 A) takeWhile takeWhile"
   195   unfolding takeWhile_def by transfer_prover
   196 
   197 lemma dropWhile_transfer [transfer_rule]:
   198   "((A ===> op =) ===> list_all2 A ===> list_all2 A) dropWhile dropWhile"
   199   unfolding dropWhile_def by transfer_prover
   200 
   201 lemma zip_transfer [transfer_rule]:
   202   "(list_all2 A ===> list_all2 B ===> list_all2 (prod_rel A B)) zip zip"
   203   unfolding zip_def by transfer_prover
   204 
   205 lemma insert_transfer [transfer_rule]:
   206   assumes [transfer_rule]: "bi_unique A"
   207   shows "(A ===> list_all2 A ===> list_all2 A) List.insert List.insert"
   208   unfolding List.insert_def [abs_def] by transfer_prover
   209 
   210 lemma find_transfer [transfer_rule]:
   211   "((A ===> op =) ===> list_all2 A ===> option_rel A) List.find List.find"
   212   unfolding List.find_def by transfer_prover
   213 
   214 lemma remove1_transfer [transfer_rule]:
   215   assumes [transfer_rule]: "bi_unique A"
   216   shows "(A ===> list_all2 A ===> list_all2 A) remove1 remove1"
   217   unfolding remove1_def by transfer_prover
   218 
   219 lemma removeAll_transfer [transfer_rule]:
   220   assumes [transfer_rule]: "bi_unique A"
   221   shows "(A ===> list_all2 A ===> list_all2 A) removeAll removeAll"
   222   unfolding removeAll_def by transfer_prover
   223 
   224 lemma distinct_transfer [transfer_rule]:
   225   assumes [transfer_rule]: "bi_unique A"
   226   shows "(list_all2 A ===> op =) distinct distinct"
   227   unfolding distinct_def by transfer_prover
   228 
   229 lemma remdups_transfer [transfer_rule]:
   230   assumes [transfer_rule]: "bi_unique A"
   231   shows "(list_all2 A ===> list_all2 A) remdups remdups"
   232   unfolding remdups_def by transfer_prover
   233 
   234 lemma replicate_transfer [transfer_rule]:
   235   "(op = ===> A ===> list_all2 A) replicate replicate"
   236   unfolding replicate_def by transfer_prover
   237 
   238 lemma length_transfer [transfer_rule]:
   239   "(list_all2 A ===> op =) length length"
   240   unfolding list_size_overloaded_def by transfer_prover
   241 
   242 lemma rotate1_transfer [transfer_rule]:
   243   "(list_all2 A ===> list_all2 A) rotate1 rotate1"
   244   unfolding rotate1_def by transfer_prover
   245 
   246 lemma funpow_transfer [transfer_rule]: (* FIXME: move to Transfer.thy *)
   247   "(op = ===> (A ===> A) ===> (A ===> A)) compow compow"
   248   unfolding funpow_def by transfer_prover
   249 
   250 lemma rotate_transfer [transfer_rule]:
   251   "(op = ===> list_all2 A ===> list_all2 A) rotate rotate"
   252   unfolding rotate_def [abs_def] by transfer_prover
   253 
   254 lemma list_all2_transfer [transfer_rule]:
   255   "((A ===> B ===> op =) ===> list_all2 A ===> list_all2 B ===> op =)
   256     list_all2 list_all2"
   257   apply (subst (4) list_all2_def [abs_def])
   258   apply (subst (3) list_all2_def [abs_def])
   259   apply transfer_prover
   260   done
   261 
   262 lemma sublist_transfer [transfer_rule]:
   263   "(list_all2 A ===> set_rel (op =) ===> list_all2 A) sublist sublist"
   264   unfolding sublist_def [abs_def] by transfer_prover
   265 
   266 lemma partition_transfer [transfer_rule]:
   267   "((A ===> op =) ===> list_all2 A ===> prod_rel (list_all2 A) (list_all2 A))
   268     partition partition"
   269   unfolding partition_def by transfer_prover
   270 
   271 lemma lists_transfer [transfer_rule]:
   272   "(set_rel A ===> set_rel (list_all2 A)) lists lists"
   273   apply (rule fun_relI, rule set_relI)
   274   apply (erule lists.induct, simp)
   275   apply (simp only: set_rel_def list_all2_Cons1, metis lists.Cons)
   276   apply (erule lists.induct, simp)
   277   apply (simp only: set_rel_def list_all2_Cons2, metis lists.Cons)
   278   done
   279 
   280 lemma set_Cons_transfer [transfer_rule]:
   281   "(set_rel A ===> set_rel (list_all2 A) ===> set_rel (list_all2 A))
   282     set_Cons set_Cons"
   283   unfolding fun_rel_def set_rel_def set_Cons_def
   284   apply safe
   285   apply (simp add: list_all2_Cons1, fast)
   286   apply (simp add: list_all2_Cons2, fast)
   287   done
   288 
   289 lemma listset_transfer [transfer_rule]:
   290   "(list_all2 (set_rel A) ===> set_rel (list_all2 A)) listset listset"
   291   unfolding listset_def by transfer_prover
   292 
   293 lemma null_transfer [transfer_rule]:
   294   "(list_all2 A ===> op =) List.null List.null"
   295   unfolding fun_rel_def List.null_def by auto
   296 
   297 lemma list_all_transfer [transfer_rule]:
   298   "((A ===> op =) ===> list_all2 A ===> op =) list_all list_all"
   299   unfolding list_all_iff [abs_def] by transfer_prover
   300 
   301 lemma list_ex_transfer [transfer_rule]:
   302   "((A ===> op =) ===> list_all2 A ===> op =) list_ex list_ex"
   303   unfolding list_ex_iff [abs_def] by transfer_prover
   304 
   305 lemma splice_transfer [transfer_rule]:
   306   "(list_all2 A ===> list_all2 A ===> list_all2 A) splice splice"
   307   apply (rule fun_relI, erule list_all2_induct, simp add: fun_rel_def, simp)
   308   apply (rule fun_relI)
   309   apply (erule_tac xs=x in list_all2_induct, simp, simp add: fun_rel_def)
   310   done
   311 
   312 subsection {* Setup for lifting package *}
   313 
   314 lemma Quotient_list[quot_map]:
   315   assumes "Quotient R Abs Rep T"
   316   shows "Quotient (list_all2 R) (map Abs) (map Rep) (list_all2 T)"
   317 proof (unfold Quotient_alt_def, intro conjI allI impI)
   318   from assms have 1: "\<And>x y. T x y \<Longrightarrow> Abs x = y"
   319     unfolding Quotient_alt_def by simp
   320   fix xs ys assume "list_all2 T xs ys" thus "map Abs xs = ys"
   321     by (induct, simp, simp add: 1)
   322 next
   323   from assms have 2: "\<And>x. T (Rep x) x"
   324     unfolding Quotient_alt_def by simp
   325   fix xs show "list_all2 T (map Rep xs) xs"
   326     by (induct xs, simp, simp add: 2)
   327 next
   328   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"
   329     unfolding Quotient_alt_def by simp
   330   fix xs ys show "list_all2 R xs ys \<longleftrightarrow> list_all2 T xs (map Abs xs) \<and>
   331     list_all2 T ys (map Abs ys) \<and> map Abs xs = map Abs ys"
   332     by (induct xs ys rule: list_induct2', simp_all, metis 3)
   333 qed
   334 
   335 lemma list_invariant_commute [invariant_commute]:
   336   "list_all2 (Lifting.invariant P) = Lifting.invariant (list_all P)"
   337   apply (simp add: fun_eq_iff list_all2_def list_all_iff Lifting.invariant_def Ball_def) 
   338   apply (intro allI) 
   339   apply (induct_tac rule: list_induct2') 
   340   apply simp_all 
   341   apply metis
   342 done
   343 
   344 subsection {* Rules for quotient package *}
   345 
   346 lemma list_quotient3 [quot_thm]:
   347   assumes "Quotient3 R Abs Rep"
   348   shows "Quotient3 (list_all2 R) (map Abs) (map Rep)"
   349 proof (rule Quotient3I)
   350   from assms have "\<And>x. Abs (Rep x) = x" by (rule Quotient3_abs_rep)
   351   then show "\<And>xs. map Abs (map Rep xs) = xs" by (simp add: comp_def)
   352 next
   353   from assms have "\<And>x y. R (Rep x) (Rep y) \<longleftrightarrow> x = y" by (rule Quotient3_rel_rep)
   354   then show "\<And>xs. list_all2 R (map Rep xs) (map Rep xs)"
   355     by (simp add: list_all2_map1 list_all2_map2 list_all2_eq)
   356 next
   357   fix xs ys
   358   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)
   359   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"
   360     by (induct xs ys rule: list_induct2') auto
   361 qed
   362 
   363 declare [[mapQ3 list = (list_all2, list_quotient3)]]
   364 
   365 lemma cons_prs [quot_preserve]:
   366   assumes q: "Quotient3 R Abs Rep"
   367   shows "(Rep ---> (map Rep) ---> (map Abs)) (op #) = (op #)"
   368   by (auto simp add: fun_eq_iff comp_def Quotient3_abs_rep [OF q])
   369 
   370 lemma cons_rsp [quot_respect]:
   371   assumes q: "Quotient3 R Abs Rep"
   372   shows "(R ===> list_all2 R ===> list_all2 R) (op #) (op #)"
   373   by auto
   374 
   375 lemma nil_prs [quot_preserve]:
   376   assumes q: "Quotient3 R Abs Rep"
   377   shows "map Abs [] = []"
   378   by simp
   379 
   380 lemma nil_rsp [quot_respect]:
   381   assumes q: "Quotient3 R Abs Rep"
   382   shows "list_all2 R [] []"
   383   by simp
   384 
   385 lemma map_prs_aux:
   386   assumes a: "Quotient3 R1 abs1 rep1"
   387   and     b: "Quotient3 R2 abs2 rep2"
   388   shows "(map abs2) (map ((abs1 ---> rep2) f) (map rep1 l)) = map f l"
   389   by (induct l)
   390      (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
   391 
   392 lemma map_prs [quot_preserve]:
   393   assumes a: "Quotient3 R1 abs1 rep1"
   394   and     b: "Quotient3 R2 abs2 rep2"
   395   shows "((abs1 ---> rep2) ---> (map rep1) ---> (map abs2)) map = map"
   396   and   "((abs1 ---> id) ---> map rep1 ---> id) map = map"
   397   by (simp_all only: fun_eq_iff map_prs_aux[OF a b] comp_def)
   398     (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
   399 
   400 lemma map_rsp [quot_respect]:
   401   assumes q1: "Quotient3 R1 Abs1 Rep1"
   402   and     q2: "Quotient3 R2 Abs2 Rep2"
   403   shows "((R1 ===> R2) ===> (list_all2 R1) ===> list_all2 R2) map map"
   404   and   "((R1 ===> op =) ===> (list_all2 R1) ===> op =) map map"
   405   unfolding list_all2_eq [symmetric] by (rule map_transfer)+
   406 
   407 lemma foldr_prs_aux:
   408   assumes a: "Quotient3 R1 abs1 rep1"
   409   and     b: "Quotient3 R2 abs2 rep2"
   410   shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e"
   411   by (induct l) (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
   412 
   413 lemma foldr_prs [quot_preserve]:
   414   assumes a: "Quotient3 R1 abs1 rep1"
   415   and     b: "Quotient3 R2 abs2 rep2"
   416   shows "((abs1 ---> abs2 ---> rep2) ---> (map rep1) ---> rep2 ---> abs2) foldr = foldr"
   417   apply (simp add: fun_eq_iff)
   418   by (simp only: fun_eq_iff foldr_prs_aux[OF a b])
   419      (simp)
   420 
   421 lemma foldl_prs_aux:
   422   assumes a: "Quotient3 R1 abs1 rep1"
   423   and     b: "Quotient3 R2 abs2 rep2"
   424   shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l"
   425   by (induct l arbitrary:e) (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b])
   426 
   427 lemma foldl_prs [quot_preserve]:
   428   assumes a: "Quotient3 R1 abs1 rep1"
   429   and     b: "Quotient3 R2 abs2 rep2"
   430   shows "((abs1 ---> abs2 ---> rep1) ---> rep1 ---> (map rep2) ---> abs1) foldl = foldl"
   431   by (simp add: fun_eq_iff foldl_prs_aux [OF a b])
   432 
   433 (* induct_tac doesn't accept 'arbitrary', so we manually 'spec' *)
   434 lemma foldl_rsp[quot_respect]:
   435   assumes q1: "Quotient3 R1 Abs1 Rep1"
   436   and     q2: "Quotient3 R2 Abs2 Rep2"
   437   shows "((R1 ===> R2 ===> R1) ===> R1 ===> list_all2 R2 ===> R1) foldl foldl"
   438   by (rule foldl_transfer)
   439 
   440 lemma foldr_rsp[quot_respect]:
   441   assumes q1: "Quotient3 R1 Abs1 Rep1"
   442   and     q2: "Quotient3 R2 Abs2 Rep2"
   443   shows "((R1 ===> R2 ===> R2) ===> list_all2 R1 ===> R2 ===> R2) foldr foldr"
   444   by (rule foldr_transfer)
   445 
   446 lemma list_all2_rsp:
   447   assumes r: "\<forall>x y. R x y \<longrightarrow> (\<forall>a b. R a b \<longrightarrow> S x a = T y b)"
   448   and l1: "list_all2 R x y"
   449   and l2: "list_all2 R a b"
   450   shows "list_all2 S x a = list_all2 T y b"
   451   using l1 l2
   452   by (induct arbitrary: a b rule: list_all2_induct,
   453     auto simp: list_all2_Cons1 list_all2_Cons2 r)
   454 
   455 lemma [quot_respect]:
   456   "((R ===> R ===> op =) ===> list_all2 R ===> list_all2 R ===> op =) list_all2 list_all2"
   457   by (rule list_all2_transfer)
   458 
   459 lemma [quot_preserve]:
   460   assumes a: "Quotient3 R abs1 rep1"
   461   shows "((abs1 ---> abs1 ---> id) ---> map rep1 ---> map rep1 ---> id) list_all2 = list_all2"
   462   apply (simp add: fun_eq_iff)
   463   apply clarify
   464   apply (induct_tac xa xb rule: list_induct2')
   465   apply (simp_all add: Quotient3_abs_rep[OF a])
   466   done
   467 
   468 lemma [quot_preserve]:
   469   assumes a: "Quotient3 R abs1 rep1"
   470   shows "(list_all2 ((rep1 ---> rep1 ---> id) R) l m) = (l = m)"
   471   by (induct l m rule: list_induct2') (simp_all add: Quotient3_rel_rep[OF a])
   472 
   473 lemma list_all2_find_element:
   474   assumes a: "x \<in> set a"
   475   and b: "list_all2 R a b"
   476   shows "\<exists>y. (y \<in> set b \<and> R x y)"
   477   using b a by induct auto
   478 
   479 lemma list_all2_refl:
   480   assumes a: "\<And>x y. R x y = (R x = R y)"
   481   shows "list_all2 R x x"
   482   by (induct x) (auto simp add: a)
   483 
   484 end