1147 fun ERR s = error ("Drule.disambiguate_frees: "^s) |
1147 fun ERR s = error ("Drule.disambiguate_frees: "^s) |
1148 val ct = cprop_of thm |
1148 val ct = cprop_of thm |
1149 val t = term_of ct |
1149 val t = term_of ct |
1150 val thy = theory_of_cterm ct |
1150 val thy = theory_of_cterm ct |
1151 val frees = OldTerm.term_frees t |
1151 val frees = OldTerm.term_frees t |
1152 val freenames = add_term_free_names (t, []) |
1152 val freenames = OldTerm.add_term_free_names (t, []) |
1153 fun is_old_name n = n mem_string freenames |
1153 fun is_old_name n = n mem_string freenames |
1154 fun name_of (Free (n, _)) = n |
1154 fun name_of (Free (n, _)) = n |
1155 | name_of _ = ERR "name_of" |
1155 | name_of _ = ERR "name_of" |
1156 fun new_name' bump map n = |
1156 fun new_name' bump map n = |
1157 let val n' = n^bump in |
1157 let val n' = n^bump in |
1216 fun non_trivial_term_consts tm = |
1216 fun non_trivial_term_consts tm = |
1217 List.filter (fn c => not (c = "Trueprop" orelse |
1217 List.filter (fn c => not (c = "Trueprop" orelse |
1218 c = "All" orelse |
1218 c = "All" orelse |
1219 c = "op -->" orelse |
1219 c = "op -->" orelse |
1220 c = "op &" orelse |
1220 c = "op &" orelse |
1221 c = "op =")) (Term.term_consts tm) |
1221 c = "op =")) (OldTerm.term_consts tm) |
1222 |
1222 |
1223 fun match_consts t (* th *) = |
1223 fun match_consts t (* th *) = |
1224 let |
1224 let |
1225 fun add_consts (Const (c, _), cs) = |
1225 fun add_consts (Const (c, _), cs) = |
1226 (case c of |
1226 (case c of |
1421 |
1421 |
1422 fun INST_TYPE lambda (hth as HOLThm(rens,th)) thy = |
1422 fun INST_TYPE lambda (hth as HOLThm(rens,th)) thy = |
1423 let |
1423 let |
1424 val _ = message "INST_TYPE:" |
1424 val _ = message "INST_TYPE:" |
1425 val _ = if_debug pth hth |
1425 val _ = if_debug pth hth |
1426 val tys_before = add_term_tfrees (prop_of th,[]) |
1426 val tys_before = OldTerm.add_term_tfrees (prop_of th,[]) |
1427 val th1 = Thm.varifyT th |
1427 val th1 = Thm.varifyT th |
1428 val tys_after = add_term_tvars (prop_of th1,[]) |
1428 val tys_after = OldTerm.add_term_tvars (prop_of th1,[]) |
1429 val tyinst = map (fn (bef, iS) => |
1429 val tyinst = map (fn (bef, iS) => |
1430 (case try (Lib.assoc (TFree bef)) lambda of |
1430 (case try (Lib.assoc (TFree bef)) lambda of |
1431 SOME ty => (ctyp_of thy (TVar iS), ctyp_of thy ty) |
1431 SOME ty => (ctyp_of thy (TVar iS), ctyp_of thy ty) |
1432 | NONE => (ctyp_of thy (TVar iS), ctyp_of thy (TFree bef)) |
1432 | NONE => (ctyp_of thy (TVar iS), ctyp_of thy (TFree bef)) |
1433 )) |
1433 )) |
2090 val (HOLThm(rens,td_th)) = norm_hthm thy hth |
2090 val (HOLThm(rens,td_th)) = norm_hthm thy hth |
2091 val th2 = beta_eta_thm (td_th RS ex_imp_nonempty) |
2091 val th2 = beta_eta_thm (td_th RS ex_imp_nonempty) |
2092 val c = case concl_of th2 of |
2092 val c = case concl_of th2 of |
2093 _ $ (Const("Ex",_) $ Abs(_,_,Const("op :",_) $ _ $ c)) => c |
2093 _ $ (Const("Ex",_) $ Abs(_,_,Const("op :",_) $ _ $ c)) => c |
2094 | _ => raise ERR "new_type_definition" "Bad type definition theorem" |
2094 | _ => raise ERR "new_type_definition" "Bad type definition theorem" |
2095 val tfrees = term_tfrees c |
2095 val tfrees = OldTerm.term_tfrees c |
2096 val tnames = map fst tfrees |
2096 val tnames = map fst tfrees |
2097 val tsyn = mk_syn thy tycname |
2097 val tsyn = mk_syn thy tycname |
2098 val typ = (tycname,tnames,tsyn) |
2098 val typ = (tycname,tnames,tsyn) |
2099 val ((_, typedef_info), thy') = TypedefPackage.add_typedef false (SOME thmname) typ c NONE (rtac th2 1) thy |
2099 val ((_, typedef_info), thy') = TypedefPackage.add_typedef false (SOME thmname) typ c NONE (rtac th2 1) thy |
2100 val _ = ImportRecorder.add_typedef (SOME thmname) typ c NONE th2 |
2100 val _ = ImportRecorder.add_typedef (SOME thmname) typ c NONE th2 |
2176 SOME (cterm_of thy t)] light_nonempty |
2176 SOME (cterm_of thy t)] light_nonempty |
2177 val th2 = beta_eta_thm (td_th RS (beta_eta_thm light_nonempty')) |
2177 val th2 = beta_eta_thm (td_th RS (beta_eta_thm light_nonempty')) |
2178 val c = case concl_of th2 of |
2178 val c = case concl_of th2 of |
2179 _ $ (Const("Ex",_) $ Abs(_,_,Const("op :",_) $ _ $ c)) => c |
2179 _ $ (Const("Ex",_) $ Abs(_,_,Const("op :",_) $ _ $ c)) => c |
2180 | _ => raise ERR "type_introduction" "Bad type definition theorem" |
2180 | _ => raise ERR "type_introduction" "Bad type definition theorem" |
2181 val tfrees = term_tfrees c |
2181 val tfrees = OldTerm.term_tfrees c |
2182 val tnames = sort string_ord (map fst tfrees) |
2182 val tnames = sort string_ord (map fst tfrees) |
2183 val tsyn = mk_syn thy tycname |
2183 val tsyn = mk_syn thy tycname |
2184 val typ = (tycname,tnames,tsyn) |
2184 val typ = (tycname,tnames,tsyn) |
2185 val ((_, typedef_info), thy') = TypedefPackage.add_typedef false NONE typ c (SOME(rep_name,abs_name)) (rtac th2 1) thy |
2185 val ((_, typedef_info), thy') = TypedefPackage.add_typedef false NONE typ c (SOME(rep_name,abs_name)) (rtac th2 1) thy |
2186 val _ = ImportRecorder.add_typedef NONE typ c (SOME(rep_name,abs_name)) th2 |
2186 val _ = ImportRecorder.add_typedef NONE typ c (SOME(rep_name,abs_name)) th2 |