1011 val disj2_thm = thm "disjI2" |
1011 val disj2_thm = thm "disjI2" |
1012 |
1012 |
1013 local |
1013 local |
1014 val th = thm "not_def" |
1014 val th = thm "not_def" |
1015 val thy = theory_of_thm th |
1015 val thy = theory_of_thm th |
1016 val pp = reflexive (cterm_of thy (Const("Trueprop",boolT-->propT))) |
1016 val pp = Thm.reflexive (cterm_of thy (Const("Trueprop",boolT-->propT))) |
1017 in |
1017 in |
1018 val not_elim_thm = combination pp th |
1018 val not_elim_thm = Thm.combination pp th |
1019 end |
1019 end |
1020 |
1020 |
1021 val not_intro_thm = symmetric not_elim_thm |
1021 val not_intro_thm = Thm.symmetric not_elim_thm |
1022 val abs_thm = thm "ext" |
1022 val abs_thm = thm "ext" |
1023 val trans_thm = thm "trans" |
1023 val trans_thm = thm "trans" |
1024 val symmetry_thm = thm "sym" |
1024 val symmetry_thm = thm "sym" |
1025 val transitivity_thm = thm "trans" |
1025 val transitivity_thm = thm "trans" |
1026 val eqmp_thm = thm "iffD1" |
1026 val eqmp_thm = thm "iffD1" |
1052 val cv = cterm_of sg v |
1052 val cv = cterm_of sg v |
1053 val lc = Term.lambda v c |
1053 val lc = Term.lambda v c |
1054 val clc = Thm.cterm_of sg lc |
1054 val clc = Thm.cterm_of sg lc |
1055 val cvty = ctyp_of_term cv |
1055 val cvty = ctyp_of_term cv |
1056 val th1 = implies_elim_all th |
1056 val th1 = implies_elim_all th |
1057 val th2 = beta_eta_thm (forall_intr cv th1) |
1057 val th2 = beta_eta_thm (Thm.forall_intr cv th1) |
1058 val th3 = th2 COMP (beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME clc] gen_thm)) |
1058 val th3 = th2 COMP (beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME clc] gen_thm)) |
1059 val c = prop_of th3 |
1059 val c = prop_of th3 |
1060 val vname = fst(dest_Free v) |
1060 val vname = fst(dest_Free v) |
1061 val (cold,cnew) = case c of |
1061 val (cold,cnew) = case c of |
1062 tpc $ (Const("All",allT) $ Abs(oldname,ty,body)) => |
1062 tpc $ (Const("All",allT) $ Abs(oldname,ty,body)) => |
1070 end |
1070 end |
1071 |
1071 |
1072 fun rearrange sg tm th = |
1072 fun rearrange sg tm th = |
1073 let |
1073 let |
1074 val tm' = Envir.beta_eta_contract tm |
1074 val tm' = Envir.beta_eta_contract tm |
1075 fun find [] n = Thm.permute_prems 0 1 (implies_intr (Thm.cterm_of sg tm) th) |
1075 fun find [] n = Thm.permute_prems 0 1 (Thm.implies_intr (Thm.cterm_of sg tm) th) |
1076 | find (p::ps) n = if tm' aconv (Envir.beta_eta_contract p) |
1076 | find (p::ps) n = if tm' aconv (Envir.beta_eta_contract p) |
1077 then Thm.permute_prems n 1 th |
1077 then Thm.permute_prems n 1 th |
1078 else find ps (n+1) |
1078 else find ps (n+1) |
1079 in |
1079 in |
1080 find (prems_of th) 0 |
1080 find (prems_of th) 0 |
1256 end |
1256 end |
1257 |
1257 |
1258 fun get_isabelle_thm thyname thmname hol4conc thy = |
1258 fun get_isabelle_thm thyname thmname hol4conc thy = |
1259 let |
1259 let |
1260 val (info,hol4conc') = disamb_term hol4conc |
1260 val (info,hol4conc') = disamb_term hol4conc |
1261 val i2h_conc = symmetric (rewrite_hol4_term (HOLogic.mk_Trueprop hol4conc') thy) |
1261 val i2h_conc = Thm.symmetric (rewrite_hol4_term (HOLogic.mk_Trueprop hol4conc') thy) |
1262 val isaconc = |
1262 val isaconc = |
1263 case concl_of i2h_conc of |
1263 case concl_of i2h_conc of |
1264 Const("==",_) $ lhs $ _ => lhs |
1264 Const("==",_) $ lhs $ _ => lhs |
1265 | _ => error "get_isabelle_thm" "Bad rewrite rule" |
1265 | _ => error "get_isabelle_thm" "Bad rewrite rule" |
1266 val _ = (message "Original conclusion:"; |
1266 val _ = (message "Original conclusion:"; |
1267 if_debug prin hol4conc'; |
1267 if_debug prin hol4conc'; |
1268 message "Modified conclusion:"; |
1268 message "Modified conclusion:"; |
1269 if_debug prin isaconc) |
1269 if_debug prin isaconc) |
1270 |
1270 |
1271 fun mk_res th = HOLThm(rens_of info,equal_elim i2h_conc th) |
1271 fun mk_res th = HOLThm (rens_of info, Thm.equal_elim i2h_conc th) |
1272 in |
1272 in |
1273 case get_hol4_mapping thyname thmname thy of |
1273 case get_hol4_mapping thyname thmname thy of |
1274 SOME (SOME thmname) => |
1274 SOME (SOME thmname) => |
1275 let |
1275 let |
1276 val th1 = (SOME (PureThy.get_thm thy thmname) |
1276 val th1 = (SOME (PureThy.get_thm thy thmname) |
1318 let |
1318 let |
1319 val (a, b) = get_isabelle_thm thyname thmname hol4conc thy |
1319 val (a, b) = get_isabelle_thm thyname thmname hol4conc thy |
1320 fun warn () = |
1320 fun warn () = |
1321 let |
1321 let |
1322 val (info,hol4conc') = disamb_term hol4conc |
1322 val (info,hol4conc') = disamb_term hol4conc |
1323 val i2h_conc = symmetric (rewrite_hol4_term (HOLogic.mk_Trueprop hol4conc') thy) |
1323 val i2h_conc = Thm.symmetric (rewrite_hol4_term (HOLogic.mk_Trueprop hol4conc') thy) |
1324 in |
1324 in |
1325 case concl_of i2h_conc of |
1325 case concl_of i2h_conc of |
1326 Const("==",_) $ lhs $ _ => |
1326 Const("==",_) $ lhs $ _ => |
1327 (warning ("Failed lookup of theorem '"^thmname^"':"); |
1327 (warning ("Failed lookup of theorem '"^thmname^"':"); |
1328 writeln "Original conclusion:"; |
1328 writeln "Original conclusion:"; |
1367 |
1367 |
1368 fun intern_store_thm gen_output thyname thmname hth thy = |
1368 fun intern_store_thm gen_output thyname thmname hth thy = |
1369 let |
1369 let |
1370 val (hth' as HOLThm (args as (_,th))) = norm_hthm thy hth |
1370 val (hth' as HOLThm (args as (_,th))) = norm_hthm thy hth |
1371 val rew = rewrite_hol4_term (concl_of th) thy |
1371 val rew = rewrite_hol4_term (concl_of th) thy |
1372 val th = equal_elim rew th |
1372 val th = Thm.equal_elim rew th |
1373 val thy' = add_hol4_pending thyname thmname args thy |
1373 val thy' = add_hol4_pending thyname thmname args thy |
1374 val _ = ImportRecorder.add_hol_pending thyname thmname (hthm2thm hth') |
1374 val _ = ImportRecorder.add_hol_pending thyname thmname (hthm2thm hth') |
1375 val th = disambiguate_frees th |
1375 val th = disambiguate_frees th |
1376 val thy2 = if gen_output |
1376 val thy2 = if gen_output |
1377 then add_dump ("lemma " ^ (quotename thmname) ^ ": " ^ |
1377 then add_dump ("lemma " ^ (quotename thmname) ^ ": " ^ |
1681 val _ = if_debug pth hth2 |
1681 val _ = if_debug pth hth2 |
1682 val (info,[th1,th2]) = disamb_thms [hth1,hth2] |
1682 val (info,[th1,th2]) = disamb_thms [hth1,hth2] |
1683 val (info',v') = disamb_term_from info v |
1683 val (info',v') = disamb_term_from info v |
1684 fun strip 0 _ th = th |
1684 fun strip 0 _ th = th |
1685 | strip n (p::ps) th = |
1685 | strip n (p::ps) th = |
1686 strip (n-1) ps (implies_elim th (assume p)) |
1686 strip (n-1) ps (Thm.implies_elim th (Thm.assume p)) |
1687 | strip _ _ _ = raise ERR "CHOOSE" "strip error" |
1687 | strip _ _ _ = raise ERR "CHOOSE" "strip error" |
1688 val cv = cterm_of thy v' |
1688 val cv = cterm_of thy v' |
1689 val th2 = norm_hyps th2 |
1689 val th2 = norm_hyps th2 |
1690 val cvty = ctyp_of_term cv |
1690 val cvty = ctyp_of_term cv |
1691 val c = HOLogic.dest_Trueprop (concl_of th2) |
1691 val c = HOLogic.dest_Trueprop (concl_of th2) |
1695 | _ => raise ERR "CHOOSE" "Conclusion not existential" |
1695 | _ => raise ERR "CHOOSE" "Conclusion not existential" |
1696 val ca = cterm_of (theory_of_thm th1) a |
1696 val ca = cterm_of (theory_of_thm th1) a |
1697 val choose_thm' = beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME ca,SOME cc] choose_thm) |
1697 val choose_thm' = beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME ca,SOME cc] choose_thm) |
1698 val th21 = rearrange thy (HOLogic.mk_Trueprop (a $ v')) th2 |
1698 val th21 = rearrange thy (HOLogic.mk_Trueprop (a $ v')) th2 |
1699 val th22 = strip ((nprems_of th21)-1) (cprems_of th21) th21 |
1699 val th22 = strip ((nprems_of th21)-1) (cprems_of th21) th21 |
1700 val th23 = beta_eta_thm (forall_intr cv th22) |
1700 val th23 = beta_eta_thm (Thm.forall_intr cv th22) |
1701 val th11 = implies_elim_all (beta_eta_thm th1) |
1701 val th11 = implies_elim_all (beta_eta_thm th1) |
1702 val th' = th23 COMP (th11 COMP choose_thm') |
1702 val th' = th23 COMP (th11 COMP choose_thm') |
1703 val th = implies_intr_hyps th' |
1703 val th = implies_intr_hyps th' |
1704 val res = HOLThm(rens_of info',th) |
1704 val res = HOLThm(rens_of info',th) |
1705 val _ = message "RESULT:" |
1705 val _ = message "RESULT:" |
1794 val (f,g) = case concl_of th1 of |
1794 val (f,g) = case concl_of th1 of |
1795 _ $ (Const("op =",_) $ f $ g) => (Term.lambda v f,Term.lambda v g) |
1795 _ $ (Const("op =",_) $ f $ g) => (Term.lambda v f,Term.lambda v g) |
1796 | _ => raise ERR "mk_ABS" "Bad conclusion" |
1796 | _ => raise ERR "mk_ABS" "Bad conclusion" |
1797 val (fd,fr) = dom_rng (type_of f) |
1797 val (fd,fr) = dom_rng (type_of f) |
1798 val abs_thm' = Drule.instantiate' [SOME (ctyp_of thy fd), SOME (ctyp_of thy fr)] [SOME (cterm_of thy f), SOME (cterm_of thy g)] abs_thm |
1798 val abs_thm' = Drule.instantiate' [SOME (ctyp_of thy fd), SOME (ctyp_of thy fr)] [SOME (cterm_of thy f), SOME (cterm_of thy g)] abs_thm |
1799 val th2 = forall_intr cv th1 |
1799 val th2 = Thm.forall_intr cv th1 |
1800 val th3 = th2 COMP abs_thm' |
1800 val th3 = th2 COMP abs_thm' |
1801 val res = implies_intr_hyps th3 |
1801 val res = implies_intr_hyps th3 |
1802 in |
1802 in |
1803 res |
1803 res |
1804 end |
1804 end |
1865 val th1 = implies_elim_all (beta_eta_thm th) |
1865 val th1 = implies_elim_all (beta_eta_thm th) |
1866 val a = case concl_of th1 of |
1866 val a = case concl_of th1 of |
1867 _ $ (Const("op -->",_) $ a $ Const("False",_)) => a |
1867 _ $ (Const("op -->",_) $ a $ Const("False",_)) => a |
1868 | _ => raise ERR "NOT_INTRO" "Conclusion of bad form" |
1868 | _ => raise ERR "NOT_INTRO" "Conclusion of bad form" |
1869 val ca = cterm_of thy a |
1869 val ca = cterm_of thy a |
1870 val th2 = equal_elim (Drule.instantiate' [] [SOME ca] not_intro_thm) th1 |
1870 val th2 = Thm.equal_elim (Drule.instantiate' [] [SOME ca] not_intro_thm) th1 |
1871 val res = HOLThm(rens,implies_intr_hyps th2) |
1871 val res = HOLThm(rens,implies_intr_hyps th2) |
1872 val _ = message "RESULT:" |
1872 val _ = message "RESULT:" |
1873 val _ = if_debug pth res |
1873 val _ = if_debug pth res |
1874 in |
1874 in |
1875 (thy,res) |
1875 (thy,res) |
1882 val th1 = implies_elim_all (beta_eta_thm th) |
1882 val th1 = implies_elim_all (beta_eta_thm th) |
1883 val a = case concl_of th1 of |
1883 val a = case concl_of th1 of |
1884 _ $ (Const("Not",_) $ a) => a |
1884 _ $ (Const("Not",_) $ a) => a |
1885 | _ => raise ERR "NOT_ELIM" "Conclusion of bad form" |
1885 | _ => raise ERR "NOT_ELIM" "Conclusion of bad form" |
1886 val ca = cterm_of thy a |
1886 val ca = cterm_of thy a |
1887 val th2 = equal_elim (Drule.instantiate' [] [SOME ca] not_elim_thm) th1 |
1887 val th2 = Thm.equal_elim (Drule.instantiate' [] [SOME ca] not_elim_thm) th1 |
1888 val res = HOLThm(rens,implies_intr_hyps th2) |
1888 val res = HOLThm(rens,implies_intr_hyps th2) |
1889 val _ = message "RESULT:" |
1889 val _ = message "RESULT:" |
1890 val _ = if_debug pth res |
1890 val _ = if_debug pth res |
1891 in |
1891 in |
1892 (thy,res) |
1892 (thy,res) |
1900 val (info,th) = disamb_thm hth |
1900 val (info,th) = disamb_thm hth |
1901 val (info',tm') = disamb_term_from info tm |
1901 val (info',tm') = disamb_term_from info tm |
1902 val prems = prems_of th |
1902 val prems = prems_of th |
1903 val th1 = beta_eta_thm th |
1903 val th1 = beta_eta_thm th |
1904 val th2 = implies_elim_all th1 |
1904 val th2 = implies_elim_all th1 |
1905 val th3 = implies_intr (cterm_of thy (HOLogic.mk_Trueprop tm')) th2 |
1905 val th3 = Thm.implies_intr (cterm_of thy (HOLogic.mk_Trueprop tm')) th2 |
1906 val th4 = th3 COMP disch_thm |
1906 val th4 = th3 COMP disch_thm |
1907 val res = HOLThm(rens_of info',implies_intr_hyps th4) |
1907 val res = HOLThm (rens_of info', implies_intr_hyps th4) |
1908 val _ = message "RESULT:" |
1908 val _ = message "RESULT:" |
1909 val _ = if_debug pth res |
1909 val _ = if_debug pth res |
1910 in |
1910 in |
1911 (thy,res) |
1911 (thy,res) |
1912 end |
1912 end |
2030 (thy1,th) |
2030 (thy1,th) |
2031 val _ = ImportRecorder.add_specification names' th |
2031 val _ = ImportRecorder.add_specification names' th |
2032 val res' = Thm.unvarify_global res |
2032 val res' = Thm.unvarify_global res |
2033 val hth = HOLThm(rens,res') |
2033 val hth = HOLThm(rens,res') |
2034 val rew = rewrite_hol4_term (concl_of res') thy' |
2034 val rew = rewrite_hol4_term (concl_of res') thy' |
2035 val th = equal_elim rew res' |
2035 val th = Thm.equal_elim rew res' |
2036 fun handle_const (name,thy) = |
2036 fun handle_const (name,thy) = |
2037 let |
2037 let |
2038 val defname = Thm.def_name name |
2038 val defname = Thm.def_name name |
2039 val (newname,thy') = get_defname thyname name thy |
2039 val (newname,thy') = get_defname thyname name thy |
2040 in |
2040 in |
2110 else () |
2110 else () |
2111 val thy4 = add_hol4_pending thyname thmname args thy'' |
2111 val thy4 = add_hol4_pending thyname thmname args thy'' |
2112 val _ = ImportRecorder.add_hol_pending thyname thmname (hthm2thm hth') |
2112 val _ = ImportRecorder.add_hol_pending thyname thmname (hthm2thm hth') |
2113 |
2113 |
2114 val rew = rewrite_hol4_term (concl_of td_th) thy4 |
2114 val rew = rewrite_hol4_term (concl_of td_th) thy4 |
2115 val th = equal_elim rew (Thm.transfer thy4 td_th) |
2115 val th = Thm.equal_elim rew (Thm.transfer thy4 td_th) |
2116 val c = case HOLogic.dest_Trueprop (prop_of th) of |
2116 val c = case HOLogic.dest_Trueprop (prop_of th) of |
2117 Const("Ex",exT) $ P => |
2117 Const("Ex",exT) $ P => |
2118 let |
2118 let |
2119 val PT = domain_type exT |
2119 val PT = domain_type exT |
2120 in |
2120 in |