src/HOL/Tools/set_comprehension_pointfree.ML
changeset 51798 ad3a241def73
parent 51717 9e7d1c139569
child 55414 eab03e9cee8a
equal deleted inserted replaced
51797:182454c06a80 51798:ad3a241def73
   315 val collectE' = @{lemma "a \<notin> {x. P x} ==> (\<not> P a ==> Q) ==> Q" by auto}
   315 val collectE' = @{lemma "a \<notin> {x. P x} ==> (\<not> P a ==> Q) ==> Q" by auto}
   316 
   316 
   317 fun elim_Collect_tac ctxt = dtac @{thm iffD1[OF mem_Collect_eq]}
   317 fun elim_Collect_tac ctxt = dtac @{thm iffD1[OF mem_Collect_eq]}
   318   THEN' (REPEAT_DETERM o (eresolve_tac @{thms exE}))
   318   THEN' (REPEAT_DETERM o (eresolve_tac @{thms exE}))
   319   THEN' REPEAT_DETERM o etac @{thm conjE}
   319   THEN' REPEAT_DETERM o etac @{thm conjE}
   320   THEN' TRY o hyp_subst_tac' ctxt;
   320   THEN' TRY o hyp_subst_tac ctxt;
   321 
   321 
   322 fun intro_image_tac ctxt = rtac @{thm image_eqI}
   322 fun intro_image_tac ctxt = rtac @{thm image_eqI}
   323     THEN' (REPEAT_DETERM1 o
   323     THEN' (REPEAT_DETERM1 o
   324       (rtac @{thm refl}
   324       (rtac @{thm refl}
   325       ORELSE' rtac
   325       ORELSE' rtac
   330 
   330 
   331 fun elim_image_tac ctxt = etac @{thm imageE}
   331 fun elim_image_tac ctxt = etac @{thm imageE}
   332   THEN' REPEAT_DETERM o CHANGED o
   332   THEN' REPEAT_DETERM o CHANGED o
   333     (TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps @{thms split_paired_all prod.cases})
   333     (TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps @{thms split_paired_all prod.cases})
   334     THEN' REPEAT_DETERM o etac @{thm Pair_inject}
   334     THEN' REPEAT_DETERM o etac @{thm Pair_inject}
   335     THEN' TRY o hyp_subst_tac' ctxt)
   335     THEN' TRY o hyp_subst_tac ctxt)
   336 
   336 
   337 fun tac1_of_formula ctxt (Int (fm1, fm2)) =
   337 fun tac1_of_formula ctxt (Int (fm1, fm2)) =
   338     TRY o etac @{thm conjE}
   338     TRY o etac @{thm conjE}
   339     THEN' rtac @{thm IntI}
   339     THEN' rtac @{thm IntI}
   340     THEN' (fn i => tac1_of_formula ctxt fm2 (i + 1))
   340     THEN' (fn i => tac1_of_formula ctxt fm2 (i + 1))
   374       (atac
   374       (atac
   375        ORELSE' dtac @{thm iffD1[OF mem_Sigma_iff]}
   375        ORELSE' dtac @{thm iffD1[OF mem_Sigma_iff]}
   376        ORELSE' etac @{thm conjE}
   376        ORELSE' etac @{thm conjE}
   377        ORELSE' ((etac @{thm CollectE} ORELSE' etac collectE') THEN'
   377        ORELSE' ((etac @{thm CollectE} ORELSE' etac collectE') THEN'
   378          TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps [@{thm prod.cases}]) THEN'
   378          TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps [@{thm prod.cases}]) THEN'
   379          REPEAT_DETERM o etac @{thm Pair_inject} THEN' TRY o hyp_subst_tac' ctxt THEN' TRY o rtac @{thm refl})
   379          REPEAT_DETERM o etac @{thm Pair_inject} THEN' TRY o hyp_subst_tac ctxt THEN' TRY o rtac @{thm refl})
   380        ORELSE' (etac @{thm imageE}
   380        ORELSE' (etac @{thm imageE}
   381          THEN' (REPEAT_DETERM o CHANGED o
   381          THEN' (REPEAT_DETERM o CHANGED o
   382          (TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps @{thms split_paired_all prod.cases})
   382          (TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps @{thms split_paired_all prod.cases})
   383          THEN' REPEAT_DETERM o etac @{thm Pair_inject}
   383          THEN' REPEAT_DETERM o etac @{thm Pair_inject}
   384          THEN' TRY o hyp_subst_tac' ctxt THEN' TRY o rtac @{thm refl})))
   384          THEN' TRY o hyp_subst_tac ctxt THEN' TRY o rtac @{thm refl})))
   385        ORELSE' etac @{thm ComplE}
   385        ORELSE' etac @{thm ComplE}
   386        ORELSE' ((etac @{thm vimageE} ORELSE' etac vimageE')
   386        ORELSE' ((etac @{thm vimageE} ORELSE' etac vimageE')
   387         THEN' TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps [@{thm prod.cases}])
   387         THEN' TRY o full_simp_tac (put_simpset HOL_basic_ss ctxt addsimps [@{thm prod.cases}])
   388         THEN' TRY o hyp_subst_tac' ctxt THEN' TRY o rtac @{thm refl}))
   388         THEN' TRY o hyp_subst_tac ctxt THEN' TRY o rtac @{thm refl}))
   389 
   389 
   390 fun tac ctxt fm =
   390 fun tac ctxt fm =
   391   let
   391   let
   392     val subset_tac1 = rtac @{thm subsetI}
   392     val subset_tac1 = rtac @{thm subsetI}
   393       THEN' elim_Collect_tac ctxt
   393       THEN' elim_Collect_tac ctxt
   396     val subset_tac2 = rtac @{thm subsetI}
   396     val subset_tac2 = rtac @{thm subsetI}
   397       THEN' elim_image_tac ctxt
   397       THEN' elim_image_tac ctxt
   398       THEN' rtac @{thm iffD2[OF mem_Collect_eq]}
   398       THEN' rtac @{thm iffD2[OF mem_Collect_eq]}
   399       THEN' REPEAT_DETERM o resolve_tac @{thms exI}
   399       THEN' REPEAT_DETERM o resolve_tac @{thms exI}
   400       THEN' (TRY o REPEAT_ALL_NEW (rtac @{thm conjI}))
   400       THEN' (TRY o REPEAT_ALL_NEW (rtac @{thm conjI}))
   401       THEN' (K (TRY (FIRSTGOAL ((TRY o hyp_subst_tac' ctxt) THEN' rtac @{thm refl}))))
   401       THEN' (K (TRY (FIRSTGOAL ((TRY o hyp_subst_tac ctxt) THEN' rtac @{thm refl}))))
   402       THEN' (fn i => EVERY (rev (map_index (fn (j, f) =>
   402       THEN' (fn i => EVERY (rev (map_index (fn (j, f) =>
   403         REPEAT_DETERM (etac @{thm IntE} (i + j)) THEN tac2_of_formula ctxt f (i + j)) (strip_Int fm))))
   403         REPEAT_DETERM (etac @{thm IntE} (i + j)) THEN tac2_of_formula ctxt f (i + j)) (strip_Int fm))))
   404   in
   404   in
   405     rtac @{thm subset_antisym} THEN' subset_tac1 THEN' subset_tac2
   405     rtac @{thm subset_antisym} THEN' subset_tac1 THEN' subset_tac2
   406   end;
   406   end;