119 val protect: cterm -> cterm |
119 val protect: cterm -> cterm |
120 val protectI: thm |
120 val protectI: thm |
121 val protectD: thm |
121 val protectD: thm |
122 val protect_cong: thm |
122 val protect_cong: thm |
123 val implies_intr_protected: cterm list -> thm -> thm |
123 val implies_intr_protected: cterm list -> thm -> thm |
|
124 val termI: thm |
|
125 val mk_term: cterm -> thm |
|
126 val dest_term: thm -> cterm |
124 val freeze_all: thm -> thm |
127 val freeze_all: thm -> thm |
125 val tvars_of_terms: term list -> (indexname * sort) list |
128 val tvars_of_terms: term list -> (indexname * sort) list |
126 val vars_of_terms: term list -> (indexname * typ) list |
129 val vars_of_terms: term list -> (indexname * typ) list |
127 val tvars_of: thm -> (indexname * sort) list |
130 val tvars_of: thm -> (indexname * sort) list |
128 val vars_of: thm -> (indexname * typ) list |
131 val vars_of: thm -> (indexname * typ) list |
937 |
940 |
938 (*Calling equal_abs_elim with multiple terms*) |
941 (*Calling equal_abs_elim with multiple terms*) |
939 fun equal_abs_elim_list cts th = foldr (uncurry equal_abs_elim) th (rev cts); |
942 fun equal_abs_elim_list cts th = foldr (uncurry equal_abs_elim) th (rev cts); |
940 |
943 |
941 |
944 |
942 (** protected propositions **) |
945 (** protected propositions and embedded terms **) |
943 |
946 |
944 local |
947 local |
945 val A = cert (Free ("A", propT)); |
948 val A = cert (Free ("A", propT)); |
946 val prop_def = #1 (freeze_thaw ProtoPure.prop_def); |
949 val prop_def = #1 (freeze_thaw ProtoPure.prop_def); |
|
950 val term_def = #1 (freeze_thaw ProtoPure.term_def); |
947 in |
951 in |
948 val protect = Thm.capply (cert Logic.protectC); |
952 val protect = Thm.capply (cert Logic.protectC); |
949 val protectI = store_thm "protectI" (PureThy.kind_rule PureThy.internalK (standard |
953 val protectI = store_thm "protectI" (PureThy.kind_rule PureThy.internalK (standard |
950 (Thm.equal_elim (Thm.symmetric prop_def) (Thm.assume A)))); |
954 (Thm.equal_elim (Thm.symmetric prop_def) (Thm.assume A)))); |
951 val protectD = store_thm "protectD" (PureThy.kind_rule PureThy.internalK (standard |
955 val protectD = store_thm "protectD" (PureThy.kind_rule PureThy.internalK (standard |
952 (Thm.equal_elim prop_def (Thm.assume (protect A))))); |
956 (Thm.equal_elim prop_def (Thm.assume (protect A))))); |
953 val protect_cong = store_standard_thm_open "protect_cong" (Thm.reflexive (protect A)); |
957 val protect_cong = store_standard_thm_open "protect_cong" (Thm.reflexive (protect A)); |
|
958 |
|
959 val termI = store_thm "termI" (PureThy.kind_rule PureThy.internalK (standard |
|
960 (Thm.equal_elim (Thm.symmetric term_def) (Thm.forall_intr A (Thm.trivial A))))); |
954 end; |
961 end; |
955 |
962 |
956 fun implies_intr_protected asms th = |
963 fun implies_intr_protected asms th = |
957 let val asms' = map protect asms in |
964 let val asms' = map protect asms in |
958 implies_elim_list |
965 implies_elim_list |
959 (implies_intr_list asms th) |
966 (implies_intr_list asms th) |
960 (map (fn asm' => Thm.assume asm' RS protectD) asms') |
967 (map (fn asm' => Thm.assume asm' RS protectD) asms') |
961 |> implies_intr_list asms' |
968 |> implies_intr_list asms' |
962 end; |
969 end; |
|
970 |
|
971 fun mk_term ct = |
|
972 let |
|
973 val {thy, T, ...} = Thm.rep_cterm ct; |
|
974 val cert = Thm.cterm_of thy; |
|
975 val certT = Thm.ctyp_of thy; |
|
976 val a = certT (TVar (("'a", 0), [])); |
|
977 val x = cert (Var (("x", 0), T)); |
|
978 in Thm.instantiate ([(a, certT T)], [(x, ct)]) termI end; |
|
979 |
|
980 fun dest_term th = |
|
981 let val cprop = Thm.cprop_of th in |
|
982 if can Logic.dest_term (Thm.term_of cprop) then |
|
983 #2 (Thm.dest_comb cprop) |
|
984 else raise THM ("dest_term", 0, [th]) |
|
985 end; |
|
986 |
963 |
987 |
964 |
988 |
965 (** variations on instantiate **) |
989 (** variations on instantiate **) |
966 |
990 |
967 (*shorthand for instantiating just one variable in the current theory*) |
991 (*shorthand for instantiating just one variable in the current theory*) |