src/HOL/Tools/set_comprehension_pointfree.ML
changeset 49852 caaa1956f0da
parent 49850 873fa7156468
child 49857 7bf407d77152
equal deleted inserted replaced
49851:4d33963962fa 49852:caaa1956f0da
   128 
   128 
   129 fun mk_formula (@{const HOL.conj} $ t1 $ t2) = merge Int (mk_formula t1) (mk_formula t2)
   129 fun mk_formula (@{const HOL.conj} $ t1 $ t2) = merge Int (mk_formula t1) (mk_formula t2)
   130   | mk_formula (@{const HOL.disj} $ t1 $ t2) = merge Un (mk_formula t1) (mk_formula t2)
   130   | mk_formula (@{const HOL.disj} $ t1 $ t2) = merge Un (mk_formula t1) (mk_formula t2)
   131   | mk_formula t = apfst single (mk_atom t)
   131   | mk_formula t = apfst single (mk_atom t)
   132 
   132 
       
   133 fun strip_Int (Int (fm1, fm2)) = fm1 :: (strip_Int fm2) 
       
   134   | strip_Int fm = [fm]
   133 
   135 
   134 (* term construction *)
   136 (* term construction *)
   135 
   137 
   136 fun reorder_bounds pats t =
   138 fun reorder_bounds pats t =
   137   let
   139   let
   206 
   208 
   207 val elim_image_tac = etac @{thm imageE}
   209 val elim_image_tac = etac @{thm imageE}
   208   THEN' (TRY o REPEAT_DETERM1 o Splitter.split_asm_tac @{thms prod.split_asm})
   210   THEN' (TRY o REPEAT_DETERM1 o Splitter.split_asm_tac @{thms prod.split_asm})
   209   THEN' hyp_subst_tac
   211   THEN' hyp_subst_tac
   210 
   212 
   211 val intro_Collect_tac = rtac @{thm iffD2[OF mem_Collect_eq]}
       
   212   THEN' REPEAT_DETERM1 o resolve_tac @{thms exI}
       
   213   THEN' (TRY o (rtac @{thm conjI}))
       
   214   THEN' (TRY o hyp_subst_tac)
       
   215   THEN' rtac @{thm refl};
       
   216 
       
   217 fun tac1_of_formula (Int (fm1, fm2)) =
   213 fun tac1_of_formula (Int (fm1, fm2)) =
   218     TRY o etac @{thm conjE}
   214     TRY o etac @{thm conjE}
   219     THEN' rtac @{thm IntI}
   215     THEN' rtac @{thm IntI}
   220     THEN' (fn i => tac1_of_formula fm2 (i + 1))
   216     THEN' (fn i => tac1_of_formula fm2 (i + 1))
   221     THEN' tac1_of_formula fm1
   217     THEN' tac1_of_formula fm1
   253       THEN' elim_Collect_tac
   249       THEN' elim_Collect_tac
   254       THEN' (intro_image_tac ctxt)
   250       THEN' (intro_image_tac ctxt)
   255       THEN' (tac1_of_formula fm)
   251       THEN' (tac1_of_formula fm)
   256     val subset_tac2 = rtac @{thm subsetI}
   252     val subset_tac2 = rtac @{thm subsetI}
   257       THEN' elim_image_tac
   253       THEN' elim_image_tac
   258       THEN' intro_Collect_tac
   254       THEN' rtac @{thm iffD2[OF mem_Collect_eq]}
   259       THEN' tac2_of_formula fm
   255       THEN' REPEAT_DETERM1 o resolve_tac @{thms exI}
       
   256       THEN' (TRY o REPEAT_ALL_NEW (rtac @{thm conjI}))
       
   257       THEN' (K (SOMEGOAL ((TRY o hyp_subst_tac) THEN' rtac @{thm refl})))
       
   258       THEN' (fn i => EVERY (rev (map_index (fn (j, f) =>
       
   259         REPEAT_DETERM (etac @{thm IntE} (i + j)) THEN tac2_of_formula f (i + j)) (strip_Int fm))))
   260   in
   260   in
   261     rtac @{thm subset_antisym} THEN' subset_tac1 THEN' subset_tac2
   261     rtac @{thm subset_antisym} THEN' subset_tac1 THEN' subset_tac2
   262   end;
   262   end;
   263 
   263 
   264 
   264