1004 val disj2_thm = thm "disjI2" |
1004 val disj2_thm = thm "disjI2" |
1005 |
1005 |
1006 local |
1006 local |
1007 val th = thm "not_def" |
1007 val th = thm "not_def" |
1008 val thy = theory_of_thm th |
1008 val thy = theory_of_thm th |
1009 val pp = Thm.reflexive (cterm_of thy (Const(@{const_name "Trueprop"},HOLogic.boolT-->propT))) |
1009 val pp = Thm.reflexive (cterm_of thy (Const(@{const_name Trueprop},HOLogic.boolT-->propT))) |
1010 in |
1010 in |
1011 val not_elim_thm = Thm.combination pp th |
1011 val not_elim_thm = Thm.combination pp th |
1012 end |
1012 end |
1013 |
1013 |
1014 val not_intro_thm = Thm.symmetric not_elim_thm |
1014 val not_intro_thm = Thm.symmetric not_elim_thm |
1050 val th2 = beta_eta_thm (Thm.forall_intr cv th1) |
1050 val th2 = beta_eta_thm (Thm.forall_intr cv th1) |
1051 val th3 = th2 COMP (beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME clc] gen_thm)) |
1051 val th3 = th2 COMP (beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME clc] gen_thm)) |
1052 val c = prop_of th3 |
1052 val c = prop_of th3 |
1053 val vname = fst(dest_Free v) |
1053 val vname = fst(dest_Free v) |
1054 val (cold,cnew) = case c of |
1054 val (cold,cnew) = case c of |
1055 tpc $ (Const(@{const_name "All"},allT) $ Abs(oldname,ty,body)) => |
1055 tpc $ (Const(@{const_name All},allT) $ Abs(oldname,ty,body)) => |
1056 (Abs(oldname,dummyT,Bound 0),Abs(vname,dummyT,Bound 0)) |
1056 (Abs(oldname,dummyT,Bound 0),Abs(vname,dummyT,Bound 0)) |
1057 | tpc $ (Const(@{const_name "All"},allT) $ rest) => (tpc,tpc) |
1057 | tpc $ (Const(@{const_name All},allT) $ rest) => (tpc,tpc) |
1058 | _ => raise ERR "mk_GEN" "Unknown conclusion" |
1058 | _ => raise ERR "mk_GEN" "Unknown conclusion" |
1059 val th4 = Thm.rename_boundvars cold cnew th3 |
1059 val th4 = Thm.rename_boundvars cold cnew th3 |
1060 val res = implies_intr_hyps th4 |
1060 val res = implies_intr_hyps th4 |
1061 in |
1061 in |
1062 res |
1062 res |
1202 | NONE => NONE |
1202 | NONE => NONE |
1203 end |
1203 end |
1204 |
1204 |
1205 fun non_trivial_term_consts t = fold_aterms |
1205 fun non_trivial_term_consts t = fold_aterms |
1206 (fn Const (c, _) => |
1206 (fn Const (c, _) => |
1207 if c = "Trueprop" orelse c = "All" orelse c = "op -->" orelse c = "op &" orelse c = "op =" |
1207 if c = @{const_name Trueprop} orelse c = @{const_name All} |
|
1208 orelse c = @{const_name "op -->"} orelse c = @{const_name "op &"} orelse c = @{const_name "op ="} |
1208 then I else insert (op =) c |
1209 then I else insert (op =) c |
1209 | _ => I) t []; |
1210 | _ => I) t []; |
1210 |
1211 |
1211 fun match_consts t (* th *) = |
1212 fun match_consts t (* th *) = |
1212 let |
1213 let |
1213 fun add_consts (Const (c, _), cs) = |
1214 fun add_consts (Const (c, _), cs) = |
1214 (case c of |
1215 (case c of |
1215 "op =" => insert (op =) "==" cs |
1216 @{const_name "op ="} => insert (op =) "==" cs |
1216 | "op -->" => insert (op =) "==>" cs |
1217 | @{const_name "op -->"} => insert (op =) "==>" cs |
1217 | "All" => cs |
1218 | @{const_name All} => cs |
1218 | "all" => cs |
1219 | "all" => cs |
1219 | "op &" => cs |
1220 | @{const_name "op &"} => cs |
1220 | "Trueprop" => cs |
1221 | @{const_name Trueprop} => cs |
1221 | _ => insert (op =) c cs) |
1222 | _ => insert (op =) c cs) |
1222 | add_consts (t $ u, cs) = add_consts (t, add_consts (u, cs)) |
1223 | add_consts (t $ u, cs) = add_consts (t, add_consts (u, cs)) |
1223 | add_consts (Abs (_, _, t), cs) = add_consts (t, cs) |
1224 | add_consts (Abs (_, _, t), cs) = add_consts (t, cs) |
1224 | add_consts (_, cs) = cs |
1225 | add_consts (_, cs) = cs |
1225 val t_consts = add_consts(t,[]) |
1226 val t_consts = add_consts(t,[]) |
1651 val (info,th) = disamb_thm hth |
1652 val (info,th) = disamb_thm hth |
1652 val (info',[ex',wit']) = disamb_terms_from info [ex,wit] |
1653 val (info',[ex',wit']) = disamb_terms_from info [ex,wit] |
1653 val cwit = cterm_of thy wit' |
1654 val cwit = cterm_of thy wit' |
1654 val cty = ctyp_of_term cwit |
1655 val cty = ctyp_of_term cwit |
1655 val a = case ex' of |
1656 val a = case ex' of |
1656 (Const(@{const_name "Ex"},_) $ a) => a |
1657 (Const(@{const_name Ex},_) $ a) => a |
1657 | _ => raise ERR "EXISTS" "Argument not existential" |
1658 | _ => raise ERR "EXISTS" "Argument not existential" |
1658 val ca = cterm_of thy a |
1659 val ca = cterm_of thy a |
1659 val exists_thm' = beta_eta_thm (Drule.instantiate' [SOME cty] [SOME ca,SOME cwit] exists_thm) |
1660 val exists_thm' = beta_eta_thm (Drule.instantiate' [SOME cty] [SOME ca,SOME cwit] exists_thm) |
1660 val th1 = beta_eta_thm th |
1661 val th1 = beta_eta_thm th |
1661 val th2 = implies_elim_all th1 |
1662 val th2 = implies_elim_all th1 |
1684 val th2 = norm_hyps th2 |
1685 val th2 = norm_hyps th2 |
1685 val cvty = ctyp_of_term cv |
1686 val cvty = ctyp_of_term cv |
1686 val c = HOLogic.dest_Trueprop (concl_of th2) |
1687 val c = HOLogic.dest_Trueprop (concl_of th2) |
1687 val cc = cterm_of thy c |
1688 val cc = cterm_of thy c |
1688 val a = case concl_of th1 of |
1689 val a = case concl_of th1 of |
1689 _ $ (Const(@{const_name "Ex"},_) $ a) => a |
1690 _ $ (Const(@{const_name Ex},_) $ a) => a |
1690 | _ => raise ERR "CHOOSE" "Conclusion not existential" |
1691 | _ => raise ERR "CHOOSE" "Conclusion not existential" |
1691 val ca = cterm_of (theory_of_thm th1) a |
1692 val ca = cterm_of (theory_of_thm th1) a |
1692 val choose_thm' = beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME ca,SOME cc] choose_thm) |
1693 val choose_thm' = beta_eta_thm (Drule.instantiate' [SOME cvty] [SOME ca,SOME cc] choose_thm) |
1693 val th21 = rearrange thy (HOLogic.mk_Trueprop (a $ v')) th2 |
1694 val th21 = rearrange thy (HOLogic.mk_Trueprop (a $ v')) th2 |
1694 val th22 = strip ((nprems_of th21)-1) (cprems_of th21) th21 |
1695 val th22 = strip ((nprems_of th21)-1) (cprems_of th21) th21 |
1770 val _ = if_debug pth hth |
1771 val _ = if_debug pth hth |
1771 val (info,th) = disamb_thm hth |
1772 val (info,th) = disamb_thm hth |
1772 val (info',tm') = disamb_term_from info tm |
1773 val (info',tm') = disamb_term_from info tm |
1773 val th = norm_hyps th |
1774 val th = norm_hyps th |
1774 val ct = cterm_of thy tm' |
1775 val ct = cterm_of thy tm' |
1775 val th1 = rearrange thy (HOLogic.mk_Trueprop (Const(@{const_name "Not"},HOLogic.boolT-->HOLogic.boolT) $ tm')) th |
1776 val th1 = rearrange thy (HOLogic.mk_Trueprop (Const(@{const_name Not},HOLogic.boolT-->HOLogic.boolT) $ tm')) th |
1776 val ccontr_thm' = Drule.instantiate' [] [SOME ct] ccontr_thm |
1777 val ccontr_thm' = Drule.instantiate' [] [SOME ct] ccontr_thm |
1777 val res1 = uniq_compose ((nprems_of th1) - 1) th1 1 ccontr_thm' |
1778 val res1 = uniq_compose ((nprems_of th1) - 1) th1 1 ccontr_thm' |
1778 val res = HOLThm(rens_of info',res1) |
1779 val res = HOLThm(rens_of info',res1) |
1779 val _ = message "RESULT:" |
1780 val _ = message "RESULT:" |
1780 val _ = if_debug pth res |
1781 val _ = if_debug pth res |
1857 let |
1858 let |
1858 val _ = message "NOT_INTRO:" |
1859 val _ = message "NOT_INTRO:" |
1859 val _ = if_debug pth hth |
1860 val _ = if_debug pth hth |
1860 val th1 = implies_elim_all (beta_eta_thm th) |
1861 val th1 = implies_elim_all (beta_eta_thm th) |
1861 val a = case concl_of th1 of |
1862 val a = case concl_of th1 of |
1862 _ $ (Const(@{const_name "op -->"},_) $ a $ Const(@{const_name "False"},_)) => a |
1863 _ $ (Const(@{const_name "op -->"},_) $ a $ Const(@{const_name False},_)) => a |
1863 | _ => raise ERR "NOT_INTRO" "Conclusion of bad form" |
1864 | _ => raise ERR "NOT_INTRO" "Conclusion of bad form" |
1864 val ca = cterm_of thy a |
1865 val ca = cterm_of thy a |
1865 val th2 = Thm.equal_elim (Drule.instantiate' [] [SOME ca] not_intro_thm) th1 |
1866 val th2 = Thm.equal_elim (Drule.instantiate' [] [SOME ca] not_intro_thm) th1 |
1866 val res = HOLThm(rens,implies_intr_hyps th2) |
1867 val res = HOLThm(rens,implies_intr_hyps th2) |
1867 val _ = message "RESULT:" |
1868 val _ = message "RESULT:" |
1874 let |
1875 let |
1875 val _ = message "NOT_INTRO:" |
1876 val _ = message "NOT_INTRO:" |
1876 val _ = if_debug pth hth |
1877 val _ = if_debug pth hth |
1877 val th1 = implies_elim_all (beta_eta_thm th) |
1878 val th1 = implies_elim_all (beta_eta_thm th) |
1878 val a = case concl_of th1 of |
1879 val a = case concl_of th1 of |
1879 _ $ (Const(@{const_name "Not"},_) $ a) => a |
1880 _ $ (Const(@{const_name Not},_) $ a) => a |
1880 | _ => raise ERR "NOT_ELIM" "Conclusion of bad form" |
1881 | _ => raise ERR "NOT_ELIM" "Conclusion of bad form" |
1881 val ca = cterm_of thy a |
1882 val ca = cterm_of thy a |
1882 val th2 = Thm.equal_elim (Drule.instantiate' [] [SOME ca] not_elim_thm) th1 |
1883 val th2 = Thm.equal_elim (Drule.instantiate' [] [SOME ca] not_elim_thm) th1 |
1883 val res = HOLThm(rens,implies_intr_hyps th2) |
1884 val res = HOLThm(rens,implies_intr_hyps th2) |
1884 val _ = message "RESULT:" |
1885 val _ = message "RESULT:" |
1993 val (dT,rT) = dom_rng (type_of body) |
1994 val (dT,rT) = dom_rng (type_of body) |
1994 in |
1995 in |
1995 ("x",dT,body $ Bound 0) |
1996 ("x",dT,body $ Bound 0) |
1996 end |
1997 end |
1997 handle TYPE _ => raise ERR "new_specification" "not an abstraction type" |
1998 handle TYPE _ => raise ERR "new_specification" "not an abstraction type" |
1998 fun dest_exists (Const(@{const_name "Ex"},_) $ abody) = |
1999 fun dest_exists (Const(@{const_name Ex},_) $ abody) = |
1999 dest_eta_abs abody |
2000 dest_eta_abs abody |
2000 | dest_exists tm = |
2001 | dest_exists tm = |
2001 raise ERR "new_specification" "Bad existential formula" |
2002 raise ERR "new_specification" "Bad existential formula" |
2002 |
2003 |
2003 val (consts,_) = Library.foldl (fn ((cs,ex),cname) => |
2004 val (consts,_) = Library.foldl (fn ((cs,ex),cname) => |
2079 val _ = if_debug pth hth |
2080 val _ = if_debug pth hth |
2080 val _ = warning ("Introducing type " ^ tycname) |
2081 val _ = warning ("Introducing type " ^ tycname) |
2081 val (HOLThm(rens,td_th)) = norm_hthm thy hth |
2082 val (HOLThm(rens,td_th)) = norm_hthm thy hth |
2082 val th2 = beta_eta_thm (td_th RS ex_imp_nonempty) |
2083 val th2 = beta_eta_thm (td_th RS ex_imp_nonempty) |
2083 val c = case concl_of th2 of |
2084 val c = case concl_of th2 of |
2084 _ $ (Const(@{const_name "Ex"},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2085 _ $ (Const(@{const_name Ex},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2085 | _ => raise ERR "new_type_definition" "Bad type definition theorem" |
2086 | _ => raise ERR "new_type_definition" "Bad type definition theorem" |
2086 val tfrees = OldTerm.term_tfrees c |
2087 val tfrees = OldTerm.term_tfrees c |
2087 val tnames = map fst tfrees |
2088 val tnames = map fst tfrees |
2088 val tsyn = mk_syn thy tycname |
2089 val tsyn = mk_syn thy tycname |
2089 val typ = (tycname,tnames,tsyn) |
2090 val typ = (tycname,tnames,tsyn) |
2105 val _ = ImportRecorder.add_hol_pending thyname thmname (hthm2thm hth') |
2106 val _ = ImportRecorder.add_hol_pending thyname thmname (hthm2thm hth') |
2106 |
2107 |
2107 val rew = rewrite_hol4_term (concl_of td_th) thy4 |
2108 val rew = rewrite_hol4_term (concl_of td_th) thy4 |
2108 val th = Thm.equal_elim rew (Thm.transfer thy4 td_th) |
2109 val th = Thm.equal_elim rew (Thm.transfer thy4 td_th) |
2109 val c = case HOLogic.dest_Trueprop (prop_of th) of |
2110 val c = case HOLogic.dest_Trueprop (prop_of th) of |
2110 Const(@{const_name "Ex"},exT) $ P => |
2111 Const(@{const_name Ex},exT) $ P => |
2111 let |
2112 let |
2112 val PT = domain_type exT |
2113 val PT = domain_type exT |
2113 in |
2114 in |
2114 Const (@{const_name Collect},PT-->HOLogic.mk_setT (domain_type PT)) $ P |
2115 Const (@{const_name Collect},PT-->HOLogic.mk_setT (domain_type PT)) $ P |
2115 end |
2116 end |
2154 Drule.instantiate' [SOME (ctyp_of thy tT)] |
2155 Drule.instantiate' [SOME (ctyp_of thy tT)] |
2155 [SOME (cterm_of thy P), |
2156 [SOME (cterm_of thy P), |
2156 SOME (cterm_of thy t)] light_nonempty |
2157 SOME (cterm_of thy t)] light_nonempty |
2157 val th2 = beta_eta_thm (td_th RS (beta_eta_thm light_nonempty')) |
2158 val th2 = beta_eta_thm (td_th RS (beta_eta_thm light_nonempty')) |
2158 val c = case concl_of th2 of |
2159 val c = case concl_of th2 of |
2159 _ $ (Const(@{const_name "Ex"},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2160 _ $ (Const(@{const_name Ex},_) $ Abs(_,_,Const(@{const_name Set.member},_) $ _ $ c)) => c |
2160 | _ => raise ERR "type_introduction" "Bad type definition theorem" |
2161 | _ => raise ERR "type_introduction" "Bad type definition theorem" |
2161 val tfrees = OldTerm.term_tfrees c |
2162 val tfrees = OldTerm.term_tfrees c |
2162 val tnames = sort_strings (map fst tfrees) |
2163 val tnames = sort_strings (map fst tfrees) |
2163 val tsyn = mk_syn thy tycname |
2164 val tsyn = mk_syn thy tycname |
2164 val typ = (tycname,tnames,tsyn) |
2165 val typ = (tycname,tnames,tsyn) |