sane internal interface for add_typedef(_i);
authorwenzelm
Thu Oct 18 21:01:59 2001 +0200 (2001-10-18)
changeset 1182716ef206e6648
parent 11826 2203c7f9ec40
child 11828 ef3e51b1b4ec
sane internal interface for add_typedef(_i);
src/HOL/Tools/datatype_rep_proofs.ML
src/HOL/Tools/typedef_package.ML
     1.1 --- a/src/HOL/Tools/datatype_rep_proofs.ML	Thu Oct 18 21:01:18 2001 +0200
     1.2 +++ b/src/HOL/Tools/datatype_rep_proofs.ML	Thu Oct 18 21:01:59 2001 +0200
     1.3 @@ -181,8 +181,9 @@
     1.4  
     1.5      val thy3 = add_path flat_names big_name (foldl (fn (thy, ((((name, mx), tvs), c), name')) =>
     1.6        setmp TypedefPackage.quiet_mode true
     1.7 -        (TypedefPackage.add_typedef_i false name' (name, tvs, mx) c None
     1.8 -          (QUIET_BREADTH_FIRST (has_fewer_prems 1)
     1.9 +        (TypedefPackage.add_typedef_i false (Some name') (name, tvs, mx) c None
    1.10 +          (rtac exI 1 THEN
    1.11 +            QUIET_BREADTH_FIRST (has_fewer_prems 1)
    1.12              (resolve_tac (Funs_nonempty::rep_intrs) 1))) thy |> #1)
    1.13                (parent_path flat_names thy2, types_syntax ~~ tyvars ~~
    1.14                  (take (length newTs, consts)) ~~ new_type_names));
     2.1 --- a/src/HOL/Tools/typedef_package.ML	Thu Oct 18 21:01:18 2001 +0200
     2.2 +++ b/src/HOL/Tools/typedef_package.ML	Thu Oct 18 21:01:59 2001 +0200
     2.3 @@ -12,12 +12,12 @@
     2.4    val add_typedecls: (bstring * string list * mixfix) list -> theory -> theory
     2.5    val add_typedef_x: string -> bstring * string list * mixfix ->
     2.6      string -> string list -> thm list -> tactic option -> theory -> theory
     2.7 -  val add_typedef: bool -> string -> bstring * string list * mixfix ->
     2.8 +  val add_typedef: bool -> string option -> bstring * string list * mixfix ->
     2.9      string -> (bstring * bstring) option -> tactic -> theory -> theory *
    2.10      {type_definition: thm, set_def: thm option, Rep: thm, Rep_inverse: thm,
    2.11        Abs_inverse: thm, Rep_inject: thm, Abs_inject: thm, Rep_cases: thm, Abs_cases: thm,
    2.12        Rep_induct: thm, Abs_induct: thm}
    2.13 -  val add_typedef_i: bool -> string -> bstring * string list * mixfix ->
    2.14 +  val add_typedef_i: bool -> string option -> bstring * string list * mixfix ->
    2.15      term -> (bstring * bstring) option -> tactic -> theory -> theory *
    2.16      {type_definition: thm, set_def: thm option, Rep: thm, Rep_inverse: thm,
    2.17        Abs_inverse: thm, Rep_inject: thm, Abs_inject: thm, Rep_cases: thm, Abs_cases: thm,
    2.18 @@ -79,15 +79,15 @@
    2.19  
    2.20  (* prove_nonempty -- tactical version *)        (*exception ERROR*)
    2.21  
    2.22 -fun prove_nonempty thy cset goal (witn_names, witn_thms, witn_tac) =
    2.23 +fun prove_nonempty thy cset goal (witn1_tac, witn_names, witn_thms, witn2_tac) =
    2.24    let
    2.25      val is_def = Logic.is_equals o #prop o Thm.rep_thm;
    2.26      val thms = PureThy.get_thmss thy witn_names @ witn_thms;
    2.27      val tac =
    2.28 -      rtac exI 1 THEN
    2.29 +      witn1_tac THEN
    2.30        TRY (rewrite_goals_tac (filter is_def thms)) THEN
    2.31        TRY (REPEAT_FIRST (resolve_tac (filter_out is_def thms))) THEN
    2.32 -      if_none witn_tac (TRY (ALLGOALS (CLASET' blast_tac)));
    2.33 +      if_none witn2_tac (TRY (ALLGOALS (CLASET' blast_tac)));
    2.34    in
    2.35      message ("Proving non-emptiness of set " ^ quote (string_of_cterm cset) ^ " ...");
    2.36      prove_goalw_cterm [] (cterm_of (sign_of thy) goal) (K [tac])
    2.37 @@ -217,19 +217,20 @@
    2.38  
    2.39  (* add_typedef interfaces *)
    2.40  
    2.41 -fun gen_typedef prep_term def name typ set opt_morphs names thms tac thy =
    2.42 +fun gen_typedef prep_term def name typ set opt_morphs tac1 names thms tac2 thy =
    2.43    let
    2.44      val (cset, goal, _, typedef_result) =
    2.45        prepare_typedef prep_term def name typ set opt_morphs thy;
    2.46 -    val non_empty = prove_nonempty thy cset goal (names, thms, tac);
    2.47 +    val non_empty = prove_nonempty thy cset goal (tac1, names, thms, tac2);
    2.48      val ((thy', _), result) = (thy, non_empty) |> typedef_result;
    2.49    in (thy', result) end;
    2.50  
    2.51 -fun sane_typedef prep_term def name typ set opt_morphs tac =
    2.52 -  gen_typedef prep_term def name typ set opt_morphs [] [] (Some tac);
    2.53 +fun sane_typedef prep_term def opt_name typ set opt_morphs tac =
    2.54 +  gen_typedef prep_term def
    2.55 +    (if_none opt_name (#1 typ)) typ set opt_morphs all_tac [] [] (Some tac);
    2.56  
    2.57  fun add_typedef_x name typ set names thms tac =
    2.58 -  #1 o gen_typedef read_term true name typ set None names thms tac;
    2.59 +  #1 o gen_typedef read_term true name typ set None (Tactic.rtac exI 1) names thms tac;
    2.60  
    2.61  val add_typedef = sane_typedef read_term;
    2.62  val add_typedef_i = sane_typedef cert_term;