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