src/Pure/Isar/generic_target.ML
changeset 47290 ba9c8613ad9b
parent 47288 b79bf8288b29
child 47291 6a641856a0e9
equal deleted inserted replaced
47289:323b7d74b2a8 47290:ba9c8613ad9b
   186 (* abbrev *)
   186 (* abbrev *)
   187 
   187 
   188 fun abbrev target_abbrev prmode ((b, mx), t) lthy =
   188 fun abbrev target_abbrev prmode ((b, mx), t) lthy =
   189   let
   189   let
   190     val thy_ctxt = Proof_Context.init_global (Proof_Context.theory_of lthy);
   190     val thy_ctxt = Proof_Context.init_global (Proof_Context.theory_of lthy);
   191     val target_ctxt = Local_Theory.target_of lthy;
   191 
   192 
   192     val t' = Assumption.export_term lthy thy_ctxt t;
   193     val t' = Assumption.export_term lthy target_ctxt t;
   193     val xs = map Free (sort (Variable.fixed_ord lthy o pairself #1) (Variable.add_fixed lthy t' []));
   194     val xs = map Free (rev (Variable.add_fixed lthy t' []));
       
   195     val u = fold_rev lambda xs t';
   194     val u = fold_rev lambda xs t';
       
   195     val global_rhs = singleton (Variable.polymorphic thy_ctxt) u;
   196 
   196 
   197     val extra_tfrees =
   197     val extra_tfrees =
   198       subtract (op =) (Term.add_tfreesT (Term.fastype_of u) []) (Term.add_tfrees u []);
   198       subtract (op =) (Term.add_tfreesT (Term.fastype_of u) []) (Term.add_tfrees u []);
   199     val mx' = check_mixfix lthy (b, extra_tfrees) mx;
   199     val mx' = check_mixfix lthy (b, extra_tfrees) mx;
   200 
       
   201     val global_rhs =
       
   202       singleton (Variable.export_terms (Variable.declare_term u target_ctxt) thy_ctxt) u;
       
   203   in
   200   in
   204     lthy
   201     lthy
   205     |> target_abbrev prmode (b, mx') (global_rhs, t') xs
   202     |> target_abbrev prmode (b, mx') (global_rhs, t') xs
   206     |> Proof_Context.add_abbrev Print_Mode.internal (b, t) |> snd
   203     |> Proof_Context.add_abbrev Print_Mode.internal (b, t) |> snd
   207     |> Local_Defs.fixed_abbrev ((b, NoSyn), t)
   204     |> Local_Defs.fixed_abbrev ((b, NoSyn), t)