src/Pure/proofterm.ML
changeset 70530 81a8eba6639c
parent 70529 2ecbbe6b35db
child 70531 2d2b5a8e8d59
equal deleted inserted replaced
70529:2ecbbe6b35db 70530:81a8eba6639c
  2097   fn Oracle (name, prop, SOME Ts) => ([name], pair term (list typ) (prop, Ts)),
  2097   fn Oracle (name, prop, SOME Ts) => ([name], pair term (list typ) (prop, Ts)),
  2098   fn PThm ({serial, name, types = SOME Ts, ...}, _) => ([int_atom serial, name], list typ Ts)];
  2098   fn PThm ({serial, name, types = SOME Ts, ...}, _) => ([int_atom serial, name], list typ Ts)];
  2099 
  2099 
  2100 fun encode_export prop prf = pair term proof (prop, prf);
  2100 fun encode_export prop prf = pair term proof (prop, prf);
  2101 
  2101 
       
  2102 
       
  2103 val used_frees_type = fold_atyps (fn TFree (a, _) => Name.declare a | _ => I);
       
  2104 fun used_frees_term t = fold_types used_frees_type t #> Term.declare_term_frees t;
       
  2105 val used_frees_proof = fold_proof_terms used_frees_term used_frees_type;
       
  2106 
  2102 end;
  2107 end;
  2103 
  2108 
  2104 val declare_freesT = fold_atyps (fn TFree (a, _) => Name.declare a | _ => I);
       
  2105 fun declare_frees t =
       
  2106   fold_types declare_freesT t #>
       
  2107   fold_aterms (fn Free (x, _) => Name.declare x | _ => I) t;
       
  2108 
       
  2109 fun export_proof thy i prop prf =
  2109 fun export_proof thy i prop prf =
  2110   let
  2110   let
  2111     val free_names = Name.context
  2111     val free_names = Name.context
  2112       |> declare_frees prop
  2112       |> used_frees_term prop
  2113       |> fold_proof_terms declare_frees declare_freesT prf;
  2113       |> used_frees_proof prf;
  2114     val ([prop'], [prf']) = standard_vars free_names ([prop], [reconstruct_proof thy prop prf]);
  2114     val ([prop'], [prf']) = standard_vars free_names ([prop], [reconstruct_proof thy prop prf]);
  2115     val xml = encode_export prop' prf';
  2115     val xml = encode_export prop' prf';
  2116     val chunks = Buffer.chunks (YXML.buffer_body xml Buffer.empty);
  2116     val chunks = Buffer.chunks (YXML.buffer_body xml Buffer.empty);
  2117   in
  2117   in
  2118     chunks |> Export.export_params
  2118     chunks |> Export.export_params