417 val unknown_context = imperative (fn () => warning "Unknown context"); |
417 val unknown_context = imperative (fn () => warning "Unknown context"); |
418 |
418 |
419 |
419 |
420 (* theory transitions *) |
420 (* theory transitions *) |
421 |
421 |
|
422 val global_theory_group = |
|
423 Sign.new_group #> |
|
424 Global_Theory.begin_recent_proofs #> Theory.checkpoint; |
|
425 |
|
426 val local_theory_group = |
|
427 Local_Theory.new_group #> |
|
428 Local_Theory.raw_theory (Global_Theory.begin_recent_proofs #> Theory.checkpoint); |
|
429 |
422 fun generic_theory f = transaction (fn _ => |
430 fun generic_theory f = transaction (fn _ => |
423 (fn Theory (gthy, _) => Theory (f gthy, NONE) |
431 (fn Theory (gthy, _) => Theory (f gthy, NONE) |
424 | _ => raise UNDEF)); |
432 | _ => raise UNDEF)); |
425 |
433 |
426 fun theory' f = transaction (fn int => |
434 fun theory' f = transaction (fn int => |
427 (fn Theory (Context.Theory thy, _) => |
435 (fn Theory (Context.Theory thy, _) => |
428 let val thy' = thy |
436 let val thy' = thy |
429 |> Sign.new_group |
437 |> global_theory_group |
430 |> Theory.checkpoint |
|
431 |> f int |
438 |> f int |
432 |> Sign.reset_group; |
439 |> Sign.reset_group; |
433 in Theory (Context.Theory thy', NONE) end |
440 in Theory (Context.Theory thy', NONE) end |
434 | _ => raise UNDEF)); |
441 | _ => raise UNDEF)); |
435 |
442 |
452 fun local_theory_presentation loc f = present_transaction (fn int => |
459 fun local_theory_presentation loc f = present_transaction (fn int => |
453 (fn Theory (gthy, _) => |
460 (fn Theory (gthy, _) => |
454 let |
461 let |
455 val finish = loc_finish loc gthy; |
462 val finish = loc_finish loc gthy; |
456 val lthy' = loc_begin loc gthy |
463 val lthy' = loc_begin loc gthy |
457 |> Local_Theory.new_group |
464 |> local_theory_group |
458 |> f int |
465 |> f int |
459 |> Local_Theory.reset_group; |
466 |> Local_Theory.reset_group; |
460 in Theory (finish lthy', SOME lthy') end |
467 in Theory (finish lthy', SOME lthy') end |
461 | _ => raise UNDEF)); |
468 | _ => raise UNDEF)); |
462 |
469 |
504 | _ => raise UNDEF)); |
511 | _ => raise UNDEF)); |
505 |
512 |
506 in |
513 in |
507 |
514 |
508 fun local_theory_to_proof' loc f = begin_proof |
515 fun local_theory_to_proof' loc f = begin_proof |
509 (fn int => fn gthy => f int (Local_Theory.new_group (loc_begin loc gthy))) |
516 (fn int => fn gthy => f int (local_theory_group (loc_begin loc gthy))) |
510 (fn gthy => loc_finish loc gthy o Local_Theory.reset_group); |
517 (fn gthy => loc_finish loc gthy o Local_Theory.reset_group); |
511 |
518 |
512 fun local_theory_to_proof loc f = local_theory_to_proof' loc (K f); |
519 fun local_theory_to_proof loc f = local_theory_to_proof' loc (K f); |
513 |
520 |
514 fun theory_to_proof f = begin_proof |
521 fun theory_to_proof f = begin_proof |
515 (K (fn Context.Theory thy => f (Theory.checkpoint (Sign.new_group thy)) | _ => raise UNDEF)) |
522 (K (fn Context.Theory thy => f (global_theory_group thy) | _ => raise UNDEF)) |
516 (K (Context.Theory o Sign.reset_group o Proof_Context.theory_of)); |
523 (K (Context.Theory o Sign.reset_group o Proof_Context.theory_of)); |
517 |
524 |
518 end; |
525 end; |
519 |
526 |
520 val forget_proof = transaction (fn _ => |
527 val forget_proof = transaction (fn _ => |