86 val freeT = HOLogic.unitT --> lazyT |
86 val freeT = HOLogic.unitT --> lazyT |
87 val lazyT' = Type (\<^type_name>\<open>lazy\<close>, [lazyT]) |
87 val lazyT' = Type (\<^type_name>\<open>lazy\<close>, [lazyT]) |
88 val def = Logic.all_const freeT $ absdummy freeT (Logic.mk_equals ( |
88 val def = Logic.all_const freeT $ absdummy freeT (Logic.mk_equals ( |
89 Free (name, (freeT --> eagerT)) $ Bound 0, |
89 Free (name, (freeT --> eagerT)) $ Bound 0, |
90 lazy_ctr $ (Const (\<^const_name>\<open>delay\<close>, (freeT --> lazyT')) $ Bound 0))) |
90 lazy_ctr $ (Const (\<^const_name>\<open>delay\<close>, (freeT --> lazyT')) $ Bound 0))) |
91 val lthy' = Local_Theory.open_target lthy |
91 val lthy' = (snd o Local_Theory.begin_nested) lthy |
92 val ((t, (_, thm)), lthy') = Specification.definition NONE [] [] |
92 val ((t, (_, thm)), lthy') = Specification.definition NONE [] [] |
93 ((Thm.def_binding (Binding.name name), []), def) lthy' |
93 ((Thm.def_binding (Binding.name name), []), def) lthy' |
94 val lthy' = Specification.notation true ("", false) [(t, Mixfix.mixfix "_")] lthy' |
94 val lthy' = Specification.notation true ("", false) [(t, Mixfix.mixfix "_")] lthy' |
95 val lthy = Local_Theory.close_target lthy' |
95 val lthy = Local_Theory.end_nested lthy' |
96 val def_thm = singleton (Proof_Context.export lthy' lthy) thm |
96 val def_thm = singleton (Proof_Context.export lthy' lthy) thm |
97 in |
97 in |
98 (def_thm, lthy) |
98 (def_thm, lthy) |
99 end; |
99 end; |
100 |
100 |
236 { overloaded=false } |
236 { overloaded=false } |
237 (binding, rev (Term.add_tfreesT eager_type []), Mixfix.NoSyn) |
237 (binding, rev (Term.add_tfreesT eager_type []), Mixfix.NoSyn) |
238 (Const (\<^const_name>\<open>top\<close>, Type (\<^type_name>\<open>set\<close>, [eager_type]))) |
238 (Const (\<^const_name>\<open>top\<close>, Type (\<^type_name>\<open>set\<close>, [eager_type]))) |
239 NONE |
239 NONE |
240 (fn ctxt => resolve_tac ctxt [@{thm UNIV_witness}] 1) |
240 (fn ctxt => resolve_tac ctxt [@{thm UNIV_witness}] 1) |
241 o Local_Theory.open_target) lthy |
241 o (snd o Local_Theory.begin_nested)) lthy |
242 in |
242 in |
243 (binding, result, Local_Theory.close_target lthy1) |
243 (binding, result, Local_Theory.end_nested lthy1) |
244 end; |
244 end; |
245 |
245 |
246 val (typedef_binding, (_, info), lthy2) = mk_lazy_typedef (short_lazy_type_name, eagerT) lthy1 |
246 val (typedef_binding, (_, info), lthy2) = mk_lazy_typedef (short_lazy_type_name, eagerT) lthy1 |
247 |
247 |
248 val lazy_type = Type (Local_Theory.full_name lthy2 typedef_binding, type_args) |
248 val lazy_type = Type (Local_Theory.full_name lthy2 typedef_binding, type_args) |
289 |
289 |
290 fun mk_def (name, T, rhs) lthy = |
290 fun mk_def (name, T, rhs) lthy = |
291 let |
291 let |
292 val binding = Binding.name name |
292 val binding = Binding.name name |
293 val ((_, (_, thm)), lthy1) = |
293 val ((_, (_, thm)), lthy1) = |
294 Local_Theory.open_target lthy |
294 (snd o Local_Theory.begin_nested) lthy |
295 |> Specification.definition NONE [] [] ((Thm.def_binding binding, []), rhs) |
295 |> Specification.definition NONE [] [] ((Thm.def_binding binding, []), rhs) |
296 val lthy2 = Local_Theory.close_target lthy1 |
296 val lthy2 = Local_Theory.end_nested lthy1 |
297 val def_thm = hd (Proof_Context.export lthy1 lthy2 [thm]) |
297 val def_thm = hd (Proof_Context.export lthy1 lthy2 [thm]) |
298 in |
298 in |
299 ({binding = binding, const = Const (Local_Theory.full_name lthy2 binding, T), thm = def_thm}, lthy2) |
299 ({binding = binding, const = Const (Local_Theory.full_name lthy2 binding, T), thm = def_thm}, lthy2) |
300 end; |
300 end; |
301 |
301 |
353 fun tac {context, ...} = Simplifier.simp_tac |
353 fun tac {context, ...} = Simplifier.simp_tac |
354 (put_simpset HOL_basic_ss context addsimps thms) |
354 (put_simpset HOL_basic_ss context addsimps thms) |
355 1 |
355 1 |
356 val thm = Goal.prove lthy [] [] term tac |
356 val thm = Goal.prove lthy [] [] term tac |
357 val (_, lthy1) = lthy |
357 val (_, lthy1) = lthy |
358 |> Local_Theory.open_target |
358 |> (snd o Local_Theory.begin_nested) |
359 |> Local_Theory.note ((binding, []), [thm]) |
359 |> Local_Theory.note ((binding, []), [thm]) |
360 in |
360 in |
361 (thm, Local_Theory.close_target lthy1) |
361 (thm, Local_Theory.end_nested lthy1) |
362 end |
362 end |
363 fun mk_thms exec_list lthy = fold_map mk_thm exec_list lthy |
363 fun mk_thms exec_list lthy = fold_map mk_thm exec_list lthy |
364 |
364 |
365 val mk_eq = HOLogic.mk_Trueprop o HOLogic.mk_eq |
365 val mk_eq = HOLogic.mk_Trueprop o HOLogic.mk_eq |
366 |
366 |