equal
deleted
inserted
replaced
210 | G 1 = Library.setmp show_all_types true (G 0) |
210 | G 1 = Library.setmp show_all_types true (G 0) |
211 | G _ = error ("ProofKernel.smart_string_of_cterm internal error") |
211 | G _ = error ("ProofKernel.smart_string_of_cterm internal error") |
212 fun F n = |
212 fun F n = |
213 let |
213 let |
214 val str = Library.setmp show_brackets false (G n string_of_cterm) ct |
214 val str = Library.setmp show_brackets false (G n string_of_cterm) ct |
215 val cu = transform_error (read_cterm sign) (str,T) |
215 val cu = read_cterm sign (str,T) |
216 in |
216 in |
217 if match cu |
217 if match cu |
218 then quote str |
218 then quote str |
219 else F (n+1) |
219 else F (n+1) |
220 end |
220 end |
221 handle ERROR_MESSAGE mesg => F (n+1) |
221 handle ERROR mesg => F (n+1) |
222 in |
222 in |
223 transform_error (Library.setmp print_mode [] (Library.setmp Syntax.ambiguity_is_error true F)) 0 |
223 Library.setmp print_mode [] (Library.setmp Syntax.ambiguity_is_error true F) 0 |
224 end |
224 end |
225 handle ERROR_MESSAGE mesg => simple_smart_string_of_cterm ct |
225 handle ERROR mesg => simple_smart_string_of_cterm ct |
226 |
226 |
227 val smart_string_of_thm = smart_string_of_cterm o cprop_of |
227 val smart_string_of_thm = smart_string_of_cterm o cprop_of |
228 |
228 |
229 fun prth th = writeln (Library.setmp print_mode [] string_of_thm th) |
229 fun prth th = writeln (Library.setmp print_mode [] string_of_thm th) |
230 fun prc ct = writeln (Library.setmp print_mode [] string_of_cterm ct) |
230 fun prc ct = writeln (Library.setmp print_mode [] string_of_cterm ct) |
455 val protected_varnames = ref (Symtab.empty:string Symtab.table) |
455 val protected_varnames = ref (Symtab.empty:string Symtab.table) |
456 val invented_isavar = ref (IntInf.fromInt 0) |
456 val invented_isavar = ref (IntInf.fromInt 0) |
457 |
457 |
458 fun innocent_varname s = Syntax.is_identifier s andalso not (String.isPrefix "u_" s) |
458 fun innocent_varname s = Syntax.is_identifier s andalso not (String.isPrefix "u_" s) |
459 |
459 |
460 fun handle_error f d = transform_error f () handle ERROR_MESSAGE _ => d |
|
461 |
|
462 val check_name_thy = theory "Main" |
460 val check_name_thy = theory "Main" |
463 fun valid_boundvarname s = handle_error (fn () => (read_cterm check_name_thy ("SOME "^s^". True", TypeInfer.logicT); true)) false |
461 |
464 fun valid_varname s = handle_error (fn () => (read_cterm check_name_thy (s, TypeInfer.logicT); true)) false |
462 fun valid_boundvarname s = |
|
463 can (fn () => read_cterm check_name_thy ("SOME "^s^". True", TypeInfer.logicT)) (); |
|
464 |
|
465 fun valid_varname s = |
|
466 can (fn () => read_cterm check_name_thy (s, TypeInfer.logicT)) (); |
465 |
467 |
466 fun protect_varname s = |
468 fun protect_varname s = |
467 if innocent_varname s andalso valid_varname s then s else |
469 if innocent_varname s andalso valid_varname s then s else |
468 case Symtab.lookup (!protected_varnames) s of |
470 case Symtab.lookup (!protected_varnames) s of |
469 SOME t => t |
471 SOME t => t |
1251 fun mk_res th = HOLThm(rens_of info,equal_elim i2h_conc th) |
1253 fun mk_res th = HOLThm(rens_of info,equal_elim i2h_conc th) |
1252 in |
1254 in |
1253 case get_hol4_mapping thyname thmname thy of |
1255 case get_hol4_mapping thyname thmname thy of |
1254 SOME (SOME thmname) => |
1256 SOME (SOME thmname) => |
1255 let |
1257 let |
1256 val th1 = (SOME (transform_error (PureThy.get_thm thy) (Name thmname)) |
1258 val th1 = (SOME (PureThy.get_thm thy (Name thmname)) |
1257 handle ERROR_MESSAGE _ => |
1259 handle ERROR _ => |
1258 (case split_name thmname of |
1260 (case split_name thmname of |
1259 SOME (listname,idx) => (SOME (List.nth(PureThy.get_thms thy (Name listname),idx-1)) |
1261 SOME (listname,idx) => (SOME (List.nth(PureThy.get_thms thy (Name listname),idx-1)) |
1260 handle _ => NONE) |
1262 handle _ => NONE) |
1261 | NONE => NONE)) |
1263 | NONE => NONE)) |
1262 in |
1264 in |
2121 | SOME _ => HOLThm([], PureThy.get_thm thy (PureThy.Name s)) |
2123 | SOME _ => HOLThm([], PureThy.get_thm thy (PureThy.Name s)) |
2122 *) |
2124 *) |
2123 |
2125 |
2124 fun type_introduction thyname thmname tycname abs_name rep_name (P,t) hth thy = |
2126 fun type_introduction thyname thmname tycname abs_name rep_name (P,t) hth thy = |
2125 case HOL4DefThy.get thy of |
2127 case HOL4DefThy.get thy of |
2126 Replaying _ => (thy, handle_error (fn () => HOLThm([], PureThy.get_thm thy (PureThy.Name (thmname^"_@intern")))) hth) |
2128 Replaying _ => (thy, |
|
2129 HOLThm([], PureThy.get_thm thy (PureThy.Name (thmname^"_@intern"))) handle ERROR _ => hth) |
2127 | _ => |
2130 | _ => |
2128 let |
2131 let |
2129 val _ = message "TYPE_INTRO:" |
2132 val _ = message "TYPE_INTRO:" |
2130 val _ = if_debug pth hth |
2133 val _ = if_debug pth hth |
2131 val _ = warning ("Introducing type " ^ tycname ^ " (with morphisms " ^ abs_name ^ " and " ^ rep_name ^ ")") |
2134 val _ = warning ("Introducing type " ^ tycname ^ " (with morphisms " ^ abs_name ^ " and " ^ rep_name ^ ")") |