src/HOL/Tools/datatype_rep_proofs.ML
changeset 11435 bd1a7f53c11b
parent 10911 eb5721204b38
child 11471 ba2c252b55ad
     1.1 --- a/src/HOL/Tools/datatype_rep_proofs.ML	Fri Jul 20 21:58:19 2001 +0200
     1.2 +++ b/src/HOL/Tools/datatype_rep_proofs.ML	Fri Jul 20 21:59:11 2001 +0200
     1.3 @@ -29,12 +29,12 @@
     1.4  
     1.5  val (_ $ (_ $ (_ $ (distinct_f $ _) $ _))) = hd (prems_of distinct_lemma);
     1.6  
     1.7 -(* figure out internal names *)
     1.8 +
     1.9 +(** theory context references **)
    1.10  
    1.11 -val image_name = Sign.intern_const (Theory.sign_of Set.thy) "image";
    1.12 -val UNIV_name = Sign.intern_const (Theory.sign_of Set.thy) "UNIV";
    1.13 -val inj_on_name = Sign.intern_const (Theory.sign_of Fun.thy) "inj_on";
    1.14 -val inv_name = Sign.intern_const (Theory.sign_of Fun.thy) "inv";
    1.15 +val f_myinv_f = thm "f_myinv_f";
    1.16 +val myinv_f_f = thm "myinv_f_f";
    1.17 +
    1.18  
    1.19  fun exh_thm_of (dt_info : datatype_info Symtab.table) tname =
    1.20    #exhaustion (the (Symtab.lookup (dt_info, tname)));
    1.21 @@ -287,7 +287,7 @@
    1.22  	    prove_goalw_cterm [] 
    1.23  	      (cterm_of sg
    1.24  	       (HOLogic.mk_Trueprop 
    1.25 -		(Const (inj_on_name, [AbsT, UnivT] ---> HOLogic.boolT) $
    1.26 +		(Const ("Fun.inj_on", [AbsT, UnivT] ---> HOLogic.boolT) $
    1.27  		 Const (Abs_name, AbsT) $ Const (rep_set_name, UnivT))))
    1.28                (fn _ => [rtac inj_on_inverseI 1, etac thm1 1]);
    1.29  
    1.30 @@ -297,8 +297,8 @@
    1.31  	    prove_goalw_cterm []
    1.32  	      (cterm_of sg
    1.33  	       (HOLogic.mk_Trueprop
    1.34 -		(Const (inj_on_name, [RepT, setT] ---> HOLogic.boolT) $
    1.35 -		 Const (Rep_name, RepT) $ Const (UNIV_name, setT))))
    1.36 +		(Const ("Fun.inj_on", [RepT, setT] ---> HOLogic.boolT) $
    1.37 +		 Const (Rep_name, RepT) $ Const ("UNIV", setT))))
    1.38                (fn _ => [rtac inj_inverseI 1, rtac thm2 1])
    1.39  
    1.40        in (inj_Abs_thm, inj_Rep_thm) end;
    1.41 @@ -419,8 +419,8 @@
    1.42          HOLogic.mk_mem (mk_Free "x" Univ_elT i, Const (set_name, UnivT)) $
    1.43            (if i < length newTs then Const ("True", HOLogic.boolT)
    1.44             else HOLogic.mk_mem (mk_Free "x" Univ_elT i,
    1.45 -             Const (image_name, [isoT, HOLogic.mk_setT T] ---> UnivT) $
    1.46 -               Const (iso_name, isoT) $ Const (UNIV_name, HOLogic.mk_setT T)))
    1.47 +             Const ("image", [isoT, HOLogic.mk_setT T] ---> UnivT) $
    1.48 +               Const (iso_name, isoT) $ Const ("UNIV", HOLogic.mk_setT T)))
    1.49        end;
    1.50  
    1.51      val iso_t = HOLogic.mk_Trueprop (mk_conj (map mk_iso_t
    1.52 @@ -443,11 +443,6 @@
    1.53                 rtac (sym RS range_eqI) 1,
    1.54                 resolve_tac iso_char_thms 1])])));
    1.55  
    1.56 -    val Abs_inverse_thms' = (map #1 newT_iso_axms) @ map (fn r => r RS mp RS f_inv_f) iso_thms;
    1.57 -
    1.58 -    val Abs_inverse_thms = map (fn r => r RS subst) (Abs_inverse_thms' @
    1.59 -      map mk_funs_inv Abs_inverse_thms');
    1.60 -
    1.61      (* prove  inj dt_Rep_i  and  dt_Rep_i x : dt_rep_set_i *)
    1.62  
    1.63      fun prove_iso_thms (ds, (inj_thms, elem_thms)) =
    1.64 @@ -511,6 +506,14 @@
    1.65  
    1.66      val (iso_inj_thms, iso_elem_thms) = foldr prove_iso_thms
    1.67        (tl descr, (map snd newT_iso_inj_thms, map #3 newT_iso_axms));
    1.68 +    val iso_inj_thms_unfolded = drop (length (hd descr), iso_inj_thms);
    1.69 +
    1.70 +    val Abs_inverse_thms' =
    1.71 +      map #1 newT_iso_axms @
    1.72 +      map2 (fn (r_inj, r) => f_myinv_f OF [r_inj, r RS mp]) (iso_inj_thms_unfolded, iso_thms);
    1.73 +
    1.74 +    val Abs_inverse_thms = map (fn r => r RS subst) (Abs_inverse_thms' @
    1.75 +      map mk_funs_inv Abs_inverse_thms');
    1.76  
    1.77      (******************* freeness theorems for constructors *******************)
    1.78  
    1.79 @@ -586,8 +589,8 @@
    1.80      val _ = message "Proving induction rule for datatypes ...";
    1.81  
    1.82      val Rep_inverse_thms = (map (fn (_, iso, _) => iso RS subst) newT_iso_axms) @
    1.83 -      (map (fn r => r RS inv_f_f RS subst) (drop (length newTs, iso_inj_thms)));
    1.84 -    val Rep_inverse_thms' = map (fn r => r RS inv_f_f)
    1.85 +      (map (fn r => r RS myinv_f_f RS subst) (drop (length newTs, iso_inj_thms)));
    1.86 +    val Rep_inverse_thms' = map (fn r => r RS myinv_f_f)
    1.87        (drop (length newTs, iso_inj_thms));
    1.88  
    1.89      fun mk_indrule_lemma ((prems, concls), ((i, _), T)) =
    1.90 @@ -598,7 +601,7 @@
    1.91          val Abs_t = if i < length newTs then
    1.92              Const (Sign.intern_const (Theory.sign_of thy6)
    1.93                ("Abs_" ^ (nth_elem (i, new_type_names))), Univ_elT --> T)
    1.94 -          else Const (inv_name, [T --> Univ_elT, Univ_elT] ---> T) $
    1.95 +          else Const ("Inductive.myinv", [T --> Univ_elT, Univ_elT] ---> T) $
    1.96              Const (nth_elem (i, all_rep_names), T --> Univ_elT)
    1.97  
    1.98        in (prems @ [HOLogic.imp $ HOLogic.mk_mem (Rep_t,