1057 let |
1057 let |
1058 fun ERR s = error ("Drule.disambiguate_frees: "^s) |
1058 fun ERR s = error ("Drule.disambiguate_frees: "^s) |
1059 val ct = cprop_of thm |
1059 val ct = cprop_of thm |
1060 val t = term_of ct |
1060 val t = term_of ct |
1061 val thy = theory_of_cterm ct |
1061 val thy = theory_of_cterm ct |
1062 val frees = OldTerm.term_frees t |
1062 val frees = Misc_Legacy.term_frees t |
1063 val freenames = Term.add_free_names t [] |
1063 val freenames = Term.add_free_names t [] |
1064 val is_old_name = member (op =) freenames |
1064 val is_old_name = member (op =) freenames |
1065 fun name_of (Free (n, _)) = n |
1065 fun name_of (Free (n, _)) = n |
1066 | name_of _ = ERR "name_of" |
1066 | name_of _ = ERR "name_of" |
1067 fun new_name' bump map n = |
1067 fun new_name' bump map n = |
1337 |
1337 |
1338 fun INST_TYPE lambda (hth as HOLThm(rens,th)) thy = |
1338 fun INST_TYPE lambda (hth as HOLThm(rens,th)) thy = |
1339 let |
1339 let |
1340 val _ = message "INST_TYPE:" |
1340 val _ = message "INST_TYPE:" |
1341 val _ = if_debug pth hth |
1341 val _ = if_debug pth hth |
1342 val tys_before = OldTerm.add_term_tfrees (prop_of th,[]) |
1342 val tys_before = Misc_Legacy.add_term_tfrees (prop_of th,[]) |
1343 val th1 = Thm.varifyT_global th |
1343 val th1 = Thm.varifyT_global th |
1344 val tys_after = OldTerm.add_term_tvars (prop_of th1,[]) |
1344 val tys_after = Misc_Legacy.add_term_tvars (prop_of th1,[]) |
1345 val tyinst = map (fn (bef, iS) => |
1345 val tyinst = map (fn (bef, iS) => |
1346 (case try (Lib.assoc (TFree bef)) lambda of |
1346 (case try (Lib.assoc (TFree bef)) lambda of |
1347 SOME ty => (ctyp_of thy (TVar iS), ctyp_of thy ty) |
1347 SOME ty => (ctyp_of thy (TVar iS), ctyp_of thy ty) |
1348 | NONE => (ctyp_of thy (TVar iS), ctyp_of thy (TFree bef)) |
1348 | NONE => (ctyp_of thy (TVar iS), ctyp_of thy (TFree bef)) |
1349 )) |
1349 )) |
2000 val (HOLThm(rens,td_th)) = norm_hthm thy hth |
2000 val (HOLThm(rens,td_th)) = norm_hthm thy hth |
2001 val th2 = beta_eta_thm (td_th RS ex_imp_nonempty) |
2001 val th2 = beta_eta_thm (td_th RS ex_imp_nonempty) |
2002 val c = case concl_of th2 of |
2002 val c = case concl_of th2 of |
2003 _ $ (Const(@{const_name Ex},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2003 _ $ (Const(@{const_name Ex},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2004 | _ => raise ERR "new_type_definition" "Bad type definition theorem" |
2004 | _ => raise ERR "new_type_definition" "Bad type definition theorem" |
2005 val tfrees = OldTerm.term_tfrees c |
2005 val tfrees = Misc_Legacy.term_tfrees c |
2006 val tnames = map fst tfrees |
2006 val tnames = map fst tfrees |
2007 val tsyn = mk_syn thy tycname |
2007 val tsyn = mk_syn thy tycname |
2008 val typ = (tycname,tnames,tsyn) |
2008 val typ = (tycname,tnames,tsyn) |
2009 val ((_, typedef_info), thy') = |
2009 val ((_, typedef_info), thy') = |
2010 Typedef.add_typedef_global false (SOME (Binding.name thmname)) |
2010 Typedef.add_typedef_global false (SOME (Binding.name thmname)) |
2073 SOME (cterm_of thy t)] light_nonempty |
2073 SOME (cterm_of thy t)] light_nonempty |
2074 val th2 = beta_eta_thm (td_th RS (beta_eta_thm light_nonempty')) |
2074 val th2 = beta_eta_thm (td_th RS (beta_eta_thm light_nonempty')) |
2075 val c = case concl_of th2 of |
2075 val c = case concl_of th2 of |
2076 _ $ (Const(@{const_name Ex},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2076 _ $ (Const(@{const_name Ex},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2077 | _ => raise ERR "type_introduction" "Bad type definition theorem" |
2077 | _ => raise ERR "type_introduction" "Bad type definition theorem" |
2078 val tfrees = OldTerm.term_tfrees c |
2078 val tfrees = Misc_Legacy.term_tfrees c |
2079 val tnames = sort_strings (map fst tfrees) |
2079 val tnames = sort_strings (map fst tfrees) |
2080 val tsyn = mk_syn thy tycname |
2080 val tsyn = mk_syn thy tycname |
2081 val typ = (tycname,tnames,tsyn) |
2081 val typ = (tycname,tnames,tsyn) |
2082 val ((_, typedef_info), thy') = |
2082 val ((_, typedef_info), thy') = |
2083 Typedef.add_typedef_global false NONE |
2083 Typedef.add_typedef_global false NONE |