src/Pure/Isar/proof_context.ML
changeset 9133 bc3742f62b80
parent 9007 135c998d2b46
child 9196 1f6f66fe777a
equal deleted inserted replaced
9132:52286129faa5 9133:bc3742f62b80
    26   val assumptions: context -> (cterm * ((int -> tactic) * (int -> tactic))) list
    26   val assumptions: context -> (cterm * ((int -> tactic) * (int -> tactic))) list
    27   val fixed_names: context -> string list
    27   val fixed_names: context -> string list
    28   val read_typ: context -> string -> typ
    28   val read_typ: context -> string -> typ
    29   val cert_typ: context -> typ -> typ
    29   val cert_typ: context -> typ -> typ
    30   val cert_skolem: context -> string -> string
    30   val cert_skolem: context -> string -> string
       
    31   val extern_skolem: context -> term -> term
    31   val read_termTs: context -> (string * typ) list -> term list * (indexname * typ) list
    32   val read_termTs: context -> (string * typ) list -> term list * (indexname * typ) list
    32   val read_term: context -> string -> term
    33   val read_term: context -> string -> term
    33   val read_prop: context -> string -> term
    34   val read_prop: context -> string -> term
    34   val read_termT_pats: context -> (string * typ) list -> term list
    35   val read_termT_pats: context -> (string * typ) list -> term list
    35   val read_term_pats: typ -> context -> string list -> term list
    36   val read_term_pats: typ -> context -> string list -> term list
   380     handle TYPE (msg, _, _) => raise CONTEXT (msg, ctxt);
   381     handle TYPE (msg, _, _) => raise CONTEXT (msg, ctxt);
   381 
   382 
   382 
   383 
   383 (* internalize Skolem constants *)
   384 (* internalize Skolem constants *)
   384 
   385 
   385 fun get_skolem (Context {asms = (_, (fixes, _)), ...}) x = assoc (fixes, x);
   386 fun fixes_of (Context {asms = (_, (fixes, _)), ...}) = fixes;
       
   387 fun get_skolem ctxt x = assoc (fixes_of ctxt, x);
   386 
   388 
   387 fun check_skolem ctxt check x =
   389 fun check_skolem ctxt check x =
   388   if check andalso can Syntax.dest_skolem x then
   390   if check andalso can Syntax.dest_skolem x then
   389     raise CONTEXT ("Illegal reference to internal Skolem constant: " ^ quote x, ctxt)
   391     raise CONTEXT ("Illegal reference to internal Skolem constant: " ^ quote x, ctxt)
   390   else x;
   392   else x;
   403 fun cert_skolem ctxt x =
   405 fun cert_skolem ctxt x =
   404   (case get_skolem ctxt x of
   406   (case get_skolem ctxt x of
   405     None => raise CONTEXT ("Undeclared variable: " ^ quote x, ctxt)
   407     None => raise CONTEXT ("Undeclared variable: " ^ quote x, ctxt)
   406   | Some x' => x');
   408   | Some x' => x');
   407 
   409 
       
   410 
       
   411 (* externalize Skolem constants -- for printing purposes only *)
       
   412 
       
   413 fun extern_skolem ctxt =
       
   414   let
       
   415     val rev_fixes = map Library.swap (fixes_of ctxt);
       
   416 
       
   417     fun extern (t as Free (x, T)) =
       
   418           (case assoc (rev_fixes, x) of
       
   419             Some x' => Free (if get_skolem ctxt x' = Some x then x' else NameSpace.hidden x', T)
       
   420           | None => t)
       
   421       | extern (t $ u) = extern t $ extern u
       
   422       | extern (Abs (x, T, t)) = Abs (x, T, extern t)
       
   423       | extern a = a;
       
   424   in extern end
   408 
   425 
   409 
   426 
   410 (** prepare terms and propositions **)
   427 (** prepare terms and propositions **)
   411 
   428 
   412 (*
   429 (*