src/Pure/Isar/toplevel.ML
changeset 18955 fa71f2ddd2e8
parent 18811 15f9fe3064ef
child 19063 049c010c8fb7
equal deleted inserted replaced
18954:ab48b6ac9327 18955:fa71f2ddd2e8
    71   val init_theory: (bool -> theory) -> (theory -> unit) -> (theory -> unit)
    71   val init_theory: (bool -> theory) -> (theory -> unit) -> (theory -> unit)
    72     -> transition -> transition
    72     -> transition -> transition
    73   val theory: (theory -> theory) -> transition -> transition
    73   val theory: (theory -> theory) -> transition -> transition
    74   val theory': (bool -> theory -> theory) -> transition -> transition
    74   val theory': (bool -> theory -> theory) -> transition -> transition
    75   val theory_context: (theory -> Proof.context * theory) -> transition -> transition
    75   val theory_context: (theory -> Proof.context * theory) -> transition -> transition
       
    76   val local_theory: xstring option -> (local_theory -> local_theory) -> transition -> transition
    76   val theory_to_proof: (theory -> Proof.state) -> transition -> transition
    77   val theory_to_proof: (theory -> Proof.state) -> transition -> transition
    77   val proof: (Proof.state -> Proof.state) -> transition -> transition
    78   val proof: (Proof.state -> Proof.state) -> transition -> transition
    78   val proofs: (Proof.state -> Proof.state Seq.seq) -> transition -> transition
    79   val proofs: (Proof.state -> Proof.state Seq.seq) -> transition -> transition
    79   val proof': (bool -> Proof.state -> Proof.state) -> transition -> transition
    80   val proof': (bool -> Proof.state -> Proof.state) -> transition -> transition
    80   val proofs': (bool -> Proof.state -> Proof.state Seq.seq) -> transition -> transition
    81   val proofs': (bool -> Proof.state -> Proof.state Seq.seq) -> transition -> transition
   292               |> setmp Output.do_toplevel_errors false)
   293               |> setmp Output.do_toplevel_errors false)
   293           |> normal_state
   294           |> normal_state
   294           handle exn => error_state cont_node exn;
   295           handle exn => error_state cont_node exn;
   295       in
   296       in
   296         if is_stale result
   297         if is_stale result
   297         then return (error_state back_node (if_none err stale_theory))
   298         then return (error_state back_node (the_default stale_theory err))
   298         else return (result, err)
   299         else return (result, err)
   299       end;
   300       end;
   300 
   301 
   301 fun mapping f (State (SOME (node, term))) = State (SOME (History.map f node, term))
   302 fun mapping f (State (SOME (node, term))) = State (SOME (History.map f node, term))
   302   | mapping _ state = state;
   303   | mapping _ state = state;
   453 fun theory' f = app_current (fn int =>
   454 fun theory' f = app_current (fn int =>
   454   (fn Theory (thy, _) => Theory (f int thy, NONE) | _ => raise UNDEF));
   455   (fn Theory (thy, _) => Theory (f int thy, NONE) | _ => raise UNDEF));
   455 
   456 
   456 fun theory_context f = app_current
   457 fun theory_context f = app_current
   457   (K (fn Theory (thy, _) => Theory (swap (apfst SOME (f thy))) | _ => raise UNDEF));
   458   (K (fn Theory (thy, _) => Theory (swap (apfst SOME (f thy))) | _ => raise UNDEF));
       
   459 
       
   460 fun local_theory loc f = theory_context (LocalTheory.init loc #> f #> LocalTheory.exit);
   458 
   461 
   459 fun theory_to_proof f = app_current (fn int =>
   462 fun theory_to_proof f = app_current (fn int =>
   460   (fn Theory (thy, _) =>
   463   (fn Theory (thy, _) =>
   461     if ! skip_proofs then
   464     if ! skip_proofs then
   462       SkipProof ((History.init (undo_limit int) 0, #2 (Proof.global_skip_proof int (f thy))), thy)
   465       SkipProof ((History.init (undo_limit int) 0, #2 (Proof.global_skip_proof int (f thy))), thy)