105 in thm_binding "lemma" (length (flat propss) = 1) thms ctxt end)); |
105 in thm_binding "lemma" (length (flat propss) = 1) thms ctxt end)); |
106 |
106 |
107 |
107 |
108 (* old-style theorem bindings *) |
108 (* old-style theorem bindings *) |
109 |
109 |
110 structure Stored_Thms = Theory_Data |
110 structure Data = Theory_Data |
111 ( |
111 ( |
112 type T = thm list; |
112 type T = thm list; |
113 val empty = []; |
113 val empty = []; |
114 fun extend _ = []; |
114 val extend = I; |
115 fun merge _ = []; |
115 val merge = #1; |
116 ); |
116 ); |
117 |
117 |
118 fun get_stored_thms () = Stored_Thms.get (Context.the_global_context ()); |
118 fun get_stored_thms () = Data.get (Context.the_global_context ()); |
119 val get_stored_thm = hd o get_stored_thms; |
119 val get_stored_thm = hd o get_stored_thms; |
120 |
120 |
121 fun ml_store get (name, ths) = |
121 fun ml_store get (name, ths) = |
122 let |
122 let |
123 val (_, ths') = |
123 val (_, ths') = |
124 Context.>>> (Context.map_theory_result |
124 Context.>>> (Context.map_theory_result |
125 (Global_Theory.note_thms "" ((Binding.name name, []), [(ths, [])]))); |
125 (Global_Theory.note_thms "" ((Binding.name name, []), [(ths, [])]))); |
126 val _ = Theory.setup (Stored_Thms.put ths'); |
126 val _ = Theory.setup (Data.put ths'); |
127 val _ = |
127 val _ = |
128 if name = "" then () |
128 if name = "" then () |
129 else if not (ML_Syntax.is_identifier name) then |
129 else if not (ML_Syntax.is_identifier name) then |
130 error ("Cannot bind theorem(s) " ^ quote name ^ " as ML value") |
130 error ("Cannot bind theorem(s) " ^ quote name ^ " as ML value") |
131 else |
131 else |
132 ML_Compiler.eval (ML_Compiler.verbose true ML_Compiler.flags) Position.none |
132 ML_Compiler.eval (ML_Compiler.verbose true ML_Compiler.flags) Position.none |
133 (ML_Lex.tokenize ("val " ^ name ^ " = " ^ get ^ " ();")); |
133 (ML_Lex.tokenize ("val " ^ name ^ " = " ^ get ^ " ();")); |
134 val _ = Theory.setup (Stored_Thms.put []); |
134 val _ = Theory.setup (Data.put []); |
135 in () end; |
135 in () end; |
136 |
136 |
137 val store_thms = ml_store "ML_Thms.get_stored_thms"; |
137 val store_thms = ml_store "ML_Thms.get_stored_thms"; |
138 fun store_thm (name, th) = ml_store "ML_Thms.get_stored_thm" (name, [th]); |
138 fun store_thm (name, th) = ml_store "ML_Thms.get_stored_thm" (name, [th]); |
139 |
139 |