1007 |> implies_elim_all |
1007 |> implies_elim_all |
1008 |> implies_intr_hyps |
1008 |> implies_intr_hyps |
1009 |
1009 |
1010 fun mk_GEN v th sg = |
1010 fun mk_GEN v th sg = |
1011 let |
1011 let |
1012 val _ = writeln "enter mk_GEN" |
|
1013 val c = HOLogic.dest_Trueprop (concl_of th) |
1012 val c = HOLogic.dest_Trueprop (concl_of th) |
1014 val cv = cterm_of sg v |
1013 val cv = cterm_of sg v |
1015 val lc = Term.lambda v c |
1014 val lc = Term.lambda v c |
1016 val clc = Thm.cterm_of sg lc |
1015 val clc = Thm.cterm_of sg lc |
1017 val cvty = ctyp_of_term cv |
1016 val cvty = ctyp_of_term cv |
1025 (Abs(oldname,dummyT,Bound 0),Abs(vname,dummyT,Bound 0)) |
1024 (Abs(oldname,dummyT,Bound 0),Abs(vname,dummyT,Bound 0)) |
1026 | tpc $ (Const("All",allT) $ rest) => (tpc,tpc) |
1025 | tpc $ (Const("All",allT) $ rest) => (tpc,tpc) |
1027 | _ => raise ERR "mk_GEN" "Unknown conclusion" |
1026 | _ => raise ERR "mk_GEN" "Unknown conclusion" |
1028 val th4 = Thm.rename_boundvars cold cnew th3 |
1027 val th4 = Thm.rename_boundvars cold cnew th3 |
1029 val res = implies_intr_hyps th4 |
1028 val res = implies_intr_hyps th4 |
1030 val _ = writeln "exit mk_GEN" |
|
1031 in |
1029 in |
1032 res |
1030 res |
1033 end |
1031 end |
1034 |
1032 |
1035 (* rotate left k places, leaving the first j and last l premises alone |
1033 (* rotate left k places, leaving the first j and last l premises alone |
1196 fun mk_res th = HOLThm(rens_of info,equal_elim i2h_conc th) |
1194 fun mk_res th = HOLThm(rens_of info,equal_elim i2h_conc th) |
1197 in |
1195 in |
1198 case get_hol4_mapping thyname thmname thy of |
1196 case get_hol4_mapping thyname thmname thy of |
1199 SOME (SOME thmname) => |
1197 SOME (SOME thmname) => |
1200 let |
1198 let |
1201 val _ = writeln "isabelle_thm: SOME SOME" |
|
1202 val _ = message ("Looking for " ^ thmname) |
1199 val _ = message ("Looking for " ^ thmname) |
1203 val th1 = (SOME (transform_error (PureThy.get_thm thy) (Name thmname)) |
1200 val th1 = (SOME (transform_error (PureThy.get_thm thy) (Name thmname)) |
1204 handle ERROR_MESSAGE _ => |
1201 handle ERROR_MESSAGE _ => |
1205 (case split_name thmname of |
1202 (case split_name thmname of |
1206 SOME (listname,idx) => (SOME (List.nth(PureThy.get_thms thy (Name listname),idx-1)) |
1203 SOME (listname,idx) => (SOME (List.nth(PureThy.get_thms thy (Name listname),idx-1)) |
1215 | NONE => (message "NO1";error "get_isabelle_thm" "Bad mapping") |
1212 | NONE => (message "NO1";error "get_isabelle_thm" "Bad mapping") |
1216 end |
1213 end |
1217 | SOME NONE => error ("Trying to access ignored theorem " ^ thmname) |
1214 | SOME NONE => error ("Trying to access ignored theorem " ^ thmname) |
1218 | NONE => |
1215 | NONE => |
1219 let |
1216 let |
1220 val _ = writeln "isabelle_thm: None" |
|
1221 val _ = (message "Looking for conclusion:"; |
1217 val _ = (message "Looking for conclusion:"; |
1222 if_debug prin isaconc) |
1218 if_debug prin isaconc) |
1223 val cs = non_trivial_term_consts isaconc |
1219 val cs = non_trivial_term_consts isaconc |
1224 val _ = (message "Looking for consts:"; |
1220 val _ = (message "Looking for consts:"; |
1225 message (commas cs)) |
1221 message (commas cs)) |
1226 val pot_thms = Shuffler.find_potential thy isaconc |
1222 val pot_thms = Shuffler.find_potential thy isaconc |
1227 val _ = writeln ((Int.toString (length pot_thms)) ^ " potential theorems") |
1223 val _ = message ((Int.toString (length pot_thms)) ^ " potential theorems") |
1228 in |
1224 in |
1229 case Shuffler.set_prop thy isaconc pot_thms of |
1225 case Shuffler.set_prop thy isaconc pot_thms of |
1230 SOME (isaname,th) => |
1226 SOME (isaname,th) => |
1231 let |
1227 let |
1232 val hth as HOLThm args = mk_res th |
1228 val hth as HOLThm args = mk_res th |
1240 end |
1236 end |
1241 handle e => (message "Exception in get_isabelle_thm"; if_debug print_exn e handle _ => (); (thy,NONE)) |
1237 handle e => (message "Exception in get_isabelle_thm"; if_debug print_exn e handle _ => (); (thy,NONE)) |
1242 |
1238 |
1243 fun get_isabelle_thm_and_warn thyname thmname hol4conc thy = |
1239 fun get_isabelle_thm_and_warn thyname thmname hol4conc thy = |
1244 let |
1240 let |
1245 val _ = writeln "enter get_isabelle_thm_and_warn" |
|
1246 val (a, b) = get_isabelle_thm thyname thmname hol4conc thy |
1241 val (a, b) = get_isabelle_thm thyname thmname hol4conc thy |
1247 fun warn () = |
1242 fun warn () = |
1248 let |
1243 let |
1249 val sg = sign_of thy |
1244 val sg = sign_of thy |
1250 val (info,hol4conc') = disamb_term hol4conc |
1245 val (info,hol4conc') = disamb_term hol4conc |
1259 prin lhs) |
1254 prin lhs) |
1260 | _ => () |
1255 | _ => () |
1261 end |
1256 end |
1262 in |
1257 in |
1263 case b of |
1258 case b of |
1264 NONE => (warn () handle _ => (); writeln "exit get_isabelle_thm_and_warn"; (a,b)) |
1259 NONE => (warn () handle _ => (); (a,b)) |
1265 | _ => (writeln "exit get_isabelle_thm_and_warn"; (a, b)) |
1260 | _ => (a, b) |
1266 end |
1261 end |
1267 |
1262 |
1268 fun get_thm thyname thmname thy = |
1263 fun get_thm thyname thmname thy = |
1269 case get_hol4_thm thyname thmname thy of |
1264 case get_hol4_thm thyname thmname thy of |
1270 SOME hth => (writeln "got hol4 thm"; (thy,SOME hth)) |
1265 SOME hth => (thy,SOME hth) |
1271 | NONE => ((case import_proof_concl thyname thmname thy of |
1266 | NONE => ((case import_proof_concl thyname thmname thy of |
1272 SOME f => get_isabelle_thm_and_warn thyname thmname (f thy) thy |
1267 SOME f => get_isabelle_thm_and_warn thyname thmname (f thy) thy |
1273 | NONE => (message "No conclusion"; (thy,NONE))) |
1268 | NONE => (message "No conclusion"; (thy,NONE))) |
1274 handle e as IO.Io _ => (message "IO exception"; (thy,NONE)) |
1269 handle e as IO.Io _ => (message "IO exception"; (thy,NONE)) |
1275 | e as PK _ => (message "PK exception"; (thy,NONE))) |
1270 | e as PK _ => (message "PK exception"; (thy,NONE))) |
1645 (thy,res) |
1640 (thy,res) |
1646 end |
1641 end |
1647 |
1642 |
1648 fun GEN v hth thy = |
1643 fun GEN v hth thy = |
1649 let |
1644 let |
1650 val _ = writeln "GEN:" |
1645 val _ = message "GEN:" |
1651 val _ = if_debug prin v |
1646 val _ = if_debug prin v |
1652 val _ = if_debug pth hth |
1647 val _ = if_debug pth hth |
1653 val (info,th) = disamb_thm hth |
1648 val (info,th) = disamb_thm hth |
1654 val (info',v') = disamb_term_from info v |
1649 val (info',v') = disamb_term_from info v |
1655 val res = HOLThm(rens_of info',mk_GEN v' th (sign_of thy)) |
1650 val res = HOLThm(rens_of info',mk_GEN v' th (sign_of thy)) |
1656 val _ = message "RESULT:" |
1651 val _ = message "RESULT:" |
1657 val _ = if_debug pth res |
1652 val _ = if_debug pth res |
1658 val _ = writeln "exit GEN" |
|
1659 in |
1653 in |
1660 (thy,res) |
1654 (thy,res) |
1661 end |
1655 end |
1662 |
1656 |
1663 fun SPEC tm hth thy = |
1657 fun SPEC tm hth thy = |
2080 val d = case defname of NONE => "" | SOME defname => (quotename defname)^" : " |
2074 val d = case defname of NONE => "" | SOME defname => (quotename defname)^" : " |
2081 in |
2075 in |
2082 add_dump ("constdefs\n " ^ n ^ " :: \"" ^ t ^ "\" " ^ syn ^ "\n " ^ d ^ eq) thy |
2076 add_dump ("constdefs\n " ^ n ^ " :: \"" ^ t ^ "\" " ^ syn ^ "\n " ^ d ^ eq) thy |
2083 end |
2077 end |
2084 |
2078 |
|
2079 fun add_dump_syntax thy name = |
|
2080 let |
|
2081 val n = quotename name |
|
2082 val syn = Syntax.string_of_mixfix (mk_syn thy name) |
|
2083 in |
|
2084 add_dump ("syntax\n "^n^" :: _ "^syn) thy |
|
2085 end |
|
2086 |
2085 (*val type_intro_replay_history = ref (Symtab.empty:unit Symtab.table) |
2087 (*val type_intro_replay_history = ref (Symtab.empty:unit Symtab.table) |
2086 fun choose_upon_replay_history thy s dth = |
2088 fun choose_upon_replay_history thy s dth = |
2087 case Symtab.lookup (!type_intro_replay_history) s of |
2089 case Symtab.lookup (!type_intro_replay_history) s of |
2088 NONE => (type_intro_replay_history := Symtab.update (s, ()) (!type_intro_replay_history); dth) |
2090 NONE => (type_intro_replay_history := Symtab.update (s, ()) (!type_intro_replay_history); dth) |
2089 | SOME _ => HOLThm([], PureThy.get_thm thy (PureThy.Name s)) |
2091 | SOME _ => HOLThm([], PureThy.get_thm thy (PureThy.Name s)) |
2145 then "" |
2147 then "" |
2146 else "(" ^ (commafy tnames) ^ ") " |
2148 else "(" ^ (commafy tnames) ^ ") " |
2147 val proc_prop = if null tnames |
2149 val proc_prop = if null tnames |
2148 then smart_string_of_cterm |
2150 then smart_string_of_cterm |
2149 else Library.setmp show_all_types true smart_string_of_cterm |
2151 else Library.setmp show_all_types true smart_string_of_cterm |
2150 val thy = add_dump ("typedef (open) " ^ tnames_string ^ (quotename tycname) ^ " = " ^ (proc_prop (cterm_of sg c)) ^ " " ^ |
2152 val thy = add_dump ("typedef (open) " ^ tnames_string ^ (quotename tycname) ^ |
2151 (Syntax.string_of_mixfix tsyn) ^ " \n"^ |
2153 " = " ^ (proc_prop (cterm_of sg c)) ^ " " ^ |
2152 ( " apply (rule light_ex_imp_nonempty[where t="^(proc_prop (cterm_of sg t))^"]) \n")^ |
2154 (Syntax.string_of_mixfix tsyn) ^ " morphisms "^ |
2153 (" by (import " ^ thyname ^ " " ^ thmname ^ ")")) thy4 |
2155 (quote rep_name)^" "^(quote abs_name)^"\n"^ |
2154 val isa_rep_name = "Rep_"^tycname |
2156 (" apply (rule light_ex_imp_nonempty[where t="^ |
2155 val isa_abs_name = "Abs_"^tycname |
2157 (proc_prop (cterm_of sg t))^"])\n"^ |
2156 val isa_rep_name_def = isa_rep_name^"_symdest" |
2158 (" by (import " ^ thyname ^ " " ^ (quotename thmname) ^ ")"))) thy4 |
2157 val isa_abs_name_def = isa_abs_name^"_symdest" |
|
2158 val thy = add_dump_constdefs thy (SOME isa_rep_name_def) rep_name isa_rep_name rep_ty |
|
2159 val thy = add_dump_constdefs thy (SOME isa_abs_name_def) abs_name isa_abs_name abs_ty |
|
2160 val str_aty = string_of_ctyp (ctyp_of thy aty) |
2159 val str_aty = string_of_ctyp (ctyp_of thy aty) |
2161 val thy = add_dump ("lemmas " ^ (quote (thmname^"_@intern")) ^ " = typedef_hol2hollight [where a=\"a :: "^str_aty^"\" and r=r" ^ |
2160 val thy = add_dump_syntax thy rep_name |
2162 " ,\n OF "^(quotename ("type_definition_" ^ tycname)) ^ |
2161 val thy = add_dump_syntax thy abs_name |
2163 " ,\n simplified "^(quotename isa_rep_name_def)^" [symmetric] "^(quotename isa_abs_name_def)^" [symmetric]"^"]") thy |
2162 val thy = add_dump ("lemmas " ^ (quote (thmname^"_@intern")) ^ |
|
2163 " = typedef_hol2hollight \n"^ |
|
2164 " [where a=\"a :: "^str_aty^"\" and r=r" ^ |
|
2165 " ,\n OF "^(quotename ("type_definition_" ^ tycname)) ^ "]") thy |
2164 val _ = message "RESULT:" |
2166 val _ = message "RESULT:" |
2165 val _ = if_debug pth hth' |
2167 val _ = if_debug pth hth' |
2166 in |
2168 in |
2167 (thy,hth') |
2169 (thy,hth') |
2168 end |
2170 end |