src/Pure/Isar/proof_context.ML
changeset 7486 1f9eceb434db
parent 7479 b482d827899c
child 7505 a9690e9cc58a
equal deleted inserted replaced
7485:31a25b6af1b3 7486:1f9eceb434db
    37   val match_binds_i: (term list * term) list -> context -> context
    37   val match_binds_i: (term list * term) list -> context -> context
    38   val bind_propp: context * (string * (string list * string list)) -> context * term
    38   val bind_propp: context * (string * (string list * string list)) -> context * term
    39   val bind_propp_i: context * (term * (term list * term list)) -> context * term
    39   val bind_propp_i: context * (term * (term list * term list)) -> context * term
    40   val auto_bind_goal: term -> context -> context
    40   val auto_bind_goal: term -> context -> context
    41   val auto_bind_facts: string -> term list -> context -> context
    41   val auto_bind_facts: string -> term list -> context -> context
    42   val thms_closure: context -> xstring -> thm list option
       
    43   val get_thm: context -> string -> thm
    42   val get_thm: context -> string -> thm
    44   val get_thms: context -> string -> thm list
    43   val get_thms: context -> string -> thm list
    45   val get_thmss: context -> string list -> thm list
    44   val get_thmss: context -> string list -> thm list
    46   val put_thm: string * thm -> context -> context
    45   val put_thm: string * thm -> context -> context
    47   val put_thms: string * thm list -> context -> context
    46   val put_thms: string * thm list -> context -> context
    56   val assume_i: ((int -> tactic) * (int -> tactic))
    55   val assume_i: ((int -> tactic) * (int -> tactic))
    57     -> (string * context attribute list * (term * (term list * term list)) list) list
    56     -> (string * context attribute list * (term * (term list * term list)) list) list
    58     -> context -> context * ((string * thm list) list * thm list)
    57     -> context -> context * ((string * thm list) list * thm list)
    59   val fix: (string list * string option) list -> context -> context
    58   val fix: (string list * string option) list -> context -> context
    60   val fix_i: (string list * typ) list -> context -> context
    59   val fix_i: (string list * typ) list -> context -> context
    61   val transfer_used_names: context -> context -> context
       
    62   val setup: (theory -> theory) list
    60   val setup: (theory -> theory) list
    63 end;
    61 end;
    64 
    62 
    65 signature PROOF_CONTEXT_PRIVATE =
    63 signature PROOF_CONTEXT_PRIVATE =
    66 sig
    64 sig
   135   let
   133   let
   136     val prt_term = Sign.pretty_term (Theory.sign_of thy);
   134     val prt_term = Sign.pretty_term (Theory.sign_of thy);
   137     fun pretty_bind (xi, (t, T)) = prt_term (Logic.mk_equals (Var (xi, T), t));
   135     fun pretty_bind (xi, (t, T)) = prt_term (Logic.mk_equals (Var (xi, T), t));
   138   in
   136   in
   139     if Vartab.is_empty binds andalso not (! verbose) then []
   137     if Vartab.is_empty binds andalso not (! verbose) then []
   140     else [Pretty.string_of (Pretty.big_list "Term bindings:" (map pretty_bind (Vartab.dest binds)))]
   138     else [Pretty.string_of (Pretty.big_list "Term bindings:"
       
   139       (map pretty_bind (Vartab.dest binds)))]
   141   end;
   140   end;
   142 
   141 
   143 val print_binds = seq writeln o strings_of_binds;
   142 val print_binds = seq writeln o strings_of_binds;
   144 
   143 
   145 
   144 
   583 
   582 
   584 
   583 
   585 
   584 
   586 (** theorems **)
   585 (** theorems **)
   587 
   586 
   588 (* thms_closure *)
       
   589 
       
   590 fun thms_closure (Context {thy, thms, ...}) =
       
   591   let
       
   592     val global_closure = PureThy.thms_closure thy;
       
   593     fun get name =
       
   594       (case global_closure name of
       
   595         None => Symtab.lookup (thms, name)
       
   596       | some => some);
       
   597   in get end;
       
   598 
       
   599 
       
   600 (* get_thm(s) *)
   587 (* get_thm(s) *)
   601 
   588 
   602 fun get_thm (ctxt as Context {thy, thms, ...}) name =
   589 fun get_thm (ctxt as Context {thy, thms, ...}) name =
   603   (case Symtab.lookup (thms, name) of
   590   (case Symtab.lookup (thms, name) of
   604     Some [th] => th
   591     Some [th] => th
   685 end;
   672 end;
   686 
   673 
   687 
   674 
   688 (* fix *)
   675 (* fix *)
   689 
   676 
   690 fun read_skolemT (Context {defs = (_, _, _, used), ...}) None = Type.param used ("'z", logicS)
       
   691   | read_skolemT ctxt (Some s) = read_typ ctxt s;
       
   692 
       
   693 fun gen_fix prep check (ctxt, (x, raw_T)) =
   677 fun gen_fix prep check (ctxt, (x, raw_T)) =
   694   ctxt
   678   (check_skolem ctxt check x;
   695   |> declare_term (Free (check_skolem ctxt check x, prep ctxt raw_T))
   679     ctxt
   696   |> map_context (fn (thy, data, (assumes, (fixes, names)), binds, thms, defs) =>
   680     |> (case prep ctxt raw_T of None => I | Some T => declare_term (Free (x, T)))
       
   681     |> map_context (fn (thy, data, (assumes, (fixes, names)), binds, thms, defs) =>
   697       let val x' = variant names x in
   682       let val x' = variant names x in
   698         (thy, data, (assumes, ((x, Syntax.skolem x') :: fixes, x' :: names)), binds, thms, defs)
   683         (thy, data, (assumes, ((x, Syntax.skolem x') :: fixes, x' :: names)), binds, thms, defs)
   699       end);
   684       end));
   700 
   685 
   701 fun gen_fixs prep check vars ctxt =
   686 fun gen_fixs prep check vars ctxt =
   702   foldl (gen_fix prep check) (ctxt, flat (map (fn (xs, T) => map (rpair T) xs) vars));
   687   foldl (gen_fix prep check) (ctxt, flat (map (fn (xs, T) => map (rpair T) xs) vars));
   703 
   688 
   704 
   689 val fix = gen_fixs (apsome o read_typ) true;
   705 val fix = gen_fixs read_skolemT true;
   690 val fix_i = gen_fixs (Some oo cert_typ) false;
   706 val fix_i = gen_fixs cert_typ false;
   691 
   707 
       
   708 
       
   709 (* used names *)
       
   710 
       
   711 fun transfer_used_names (Context {asms = (_, (_, names)), defs = (_, _, _, used), ...}) =
       
   712   map_context (fn (thy, data, (asms, (fixes, _)), binds, thms, (types, sorts, maxidx, _)) =>
       
   713     (thy, data, (asms, (fixes, names)), binds, thms, (types, sorts, maxidx, used)));
       
   714 
   692 
   715 
   693 
   716 (** theory setup **)
   694 (** theory setup **)
   717 
   695 
   718 val setup = [ProofDataData.init];
   696 val setup = [ProofDataData.init];