src/Pure/Isar/class_target.ML
changeset 36610 bafd82950e24
parent 36462 70a1e6accac3
child 36672 bd7f659f7de5
equal deleted inserted replaced
36609:6ed6112f0a95 36610:bafd82950e24
   155   $> Element.eq_morphism thy (these_defs thy [class]);
   155   $> Element.eq_morphism thy (these_defs thy [class]);
   156 val export_morphism = #export_morph oo the_class_data;
   156 val export_morphism = #export_morph oo the_class_data;
   157 
   157 
   158 fun print_classes thy =
   158 fun print_classes thy =
   159   let
   159   let
   160     val ctxt = ProofContext.init thy;
   160     val ctxt = ProofContext.init_global thy;
   161     val algebra = Sign.classes_of thy;
   161     val algebra = Sign.classes_of thy;
   162     val arities =
   162     val arities =
   163       Symtab.empty
   163       Symtab.empty
   164       |> Symtab.fold (fn (tyco, arities) => fold (fn (class, _) =>
   164       |> Symtab.fold (fn (tyco, arities) => fold (fn (class, _) =>
   165            Symtab.map_default (class, []) (insert (op =) tyco)) arities)
   165            Symtab.map_default (class, []) (insert (op =) tyco)) arities)
   370   let
   370   let
   371     fun after_qed results =
   371     fun after_qed results =
   372       ProofContext.theory ((fold o fold) AxClass.add_classrel results);
   372       ProofContext.theory ((fold o fold) AxClass.add_classrel results);
   373   in
   373   in
   374     thy
   374     thy
   375     |> ProofContext.init
   375     |> ProofContext.init_global
   376     |> Proof.theorem NONE after_qed [[(mk_prop thy classrel, [])]]
   376     |> Proof.theorem NONE after_qed [[(mk_prop thy classrel, [])]]
   377   end;
   377   end;
   378 
   378 
   379 in
   379 in
   380 
   380 
   419   |> find_first (fn (_, (v, _)) => Binding.name_of b = v)
   419   |> find_first (fn (_, (v, _)) => Binding.name_of b = v)
   420   |> Option.map (fst o fst);
   420   |> Option.map (fst o fst);
   421 
   421 
   422 fun read_multi_arity thy (raw_tycos, raw_sorts, raw_sort) =
   422 fun read_multi_arity thy (raw_tycos, raw_sorts, raw_sort) =
   423   let
   423   let
   424     val ctxt = ProofContext.init thy;
   424     val ctxt = ProofContext.init_global thy;
   425     val all_arities = map (fn raw_tyco => ProofContext.read_arity ctxt
   425     val all_arities = map (fn raw_tyco => ProofContext.read_arity ctxt
   426       (raw_tyco, raw_sorts, raw_sort)) raw_tycos;
   426       (raw_tyco, raw_sorts, raw_sort)) raw_tycos;
   427     val tycos = map #1 all_arities;
   427     val tycos = map #1 all_arities;
   428     val (_, sorts, sort) = hd all_arities;
   428     val (_, sorts, sort) = hd all_arities;
   429     val vs = Name.names Name.context Name.aT sorts;
   429     val vs = Name.names Name.context Name.aT sorts;
   512      of SOME (_, ty') => if typ_instance (ty', ty) then SOME (ty, ty') else NONE
   512      of SOME (_, ty') => if typ_instance (ty', ty) then SOME (ty, ty') else NONE
   513       | NONE => NONE;
   513       | NONE => NONE;
   514   in
   514   in
   515     thy
   515     thy
   516     |> Theory.checkpoint
   516     |> Theory.checkpoint
   517     |> ProofContext.init
   517     |> ProofContext.init_global
   518     |> Instantiation.put (mk_instantiation ((tycos, vs, sort), params))
   518     |> Instantiation.put (mk_instantiation ((tycos, vs, sort), params))
   519     |> fold (Variable.declare_typ o TFree) vs
   519     |> fold (Variable.declare_typ o TFree) vs
   520     |> fold (Variable.declare_names o Free o snd) params
   520     |> fold (Variable.declare_names o Free o snd) params
   521     |> (Overloading.map_improvable_syntax o apfst)
   521     |> (Overloading.map_improvable_syntax o apfst)
   522          (K ((primary_constraints, []), (((improve, K NONE), false), [])))
   522          (K ((primary_constraints, []), (((improve, K NONE), false), [])))
   552   #> Local_Theory.exit_global;
   552   #> Local_Theory.exit_global;
   553 
   553 
   554 fun prove_instantiation_exit_result f tac x lthy =
   554 fun prove_instantiation_exit_result f tac x lthy =
   555   let
   555   let
   556     val morph = ProofContext.export_morphism lthy
   556     val morph = ProofContext.export_morphism lthy
   557       (ProofContext.init (ProofContext.theory_of lthy));
   557       (ProofContext.init_global (ProofContext.theory_of lthy));
   558     val y = f morph x;
   558     val y = f morph x;
   559   in
   559   in
   560     lthy
   560     lthy
   561     |> prove_instantiation_exit (fn ctxt => tac ctxt y)
   561     |> prove_instantiation_exit (fn ctxt => tac ctxt y)
   562     |> pair y
   562     |> pair y
   595     val arities = maps (fn tyco => Logic.mk_arities (tyco, sorts, sort)) tycos;
   595     val arities = maps (fn tyco => Logic.mk_arities (tyco, sorts, sort)) tycos;
   596     fun after_qed results = ProofContext.theory
   596     fun after_qed results = ProofContext.theory
   597       ((fold o fold) AxClass.add_arity results);
   597       ((fold o fold) AxClass.add_arity results);
   598   in
   598   in
   599     thy
   599     thy
   600     |> ProofContext.init
   600     |> ProofContext.init_global
   601     |> Proof.theorem NONE after_qed (map (fn t => [(t, [])]) arities)
   601     |> Proof.theorem NONE after_qed (map (fn t => [(t, [])]) arities)
   602   end;
   602   end;
   603 
   603 
   604 
   604 
   605 (** tactics and methods **)
   605 (** tactics and methods **)