src/Pure/Isar/theory_target.ML
changeset 38294 1bef02e7e1b8
parent 38293 ddd40349129d
child 38296 067d7297671e
equal deleted inserted replaced
38293:ddd40349129d 38294:1bef02e7e1b8
   156       |> Goal.norm_result
   156       |> Goal.norm_result
   157       |> PureThy.name_thm false false name;
   157       |> PureThy.name_thm false false name;
   158 
   158 
   159   in (result'', result) end;
   159   in (result'', result) end;
   160 
   160 
       
   161 fun theory_notes kind global_facts local_facts lthy =
       
   162   let
       
   163     val thy = ProofContext.theory_of lthy;
       
   164     val global_facts' = Attrib.map_facts (Attrib.attribute_i thy) global_facts;
       
   165   in
       
   166     lthy
       
   167     |> Local_Theory.theory (PureThy.note_thmss kind global_facts' #> snd)
       
   168     |> Local_Theory.target (ProofContext.note_thmss kind global_facts' #> snd)
       
   169   end;
       
   170 
       
   171 fun locale_notes locale kind global_facts local_facts lthy = 
       
   172   let
       
   173     val global_facts' = Attrib.map_facts (K I) global_facts;
       
   174     val local_facts' = Element.facts_map (Element.morph_ctxt (Local_Theory.target_morphism lthy)) local_facts;
       
   175   in
       
   176     lthy
       
   177     |> Local_Theory.theory (PureThy.note_thmss kind global_facts' #> snd)
       
   178     |> Local_Theory.target (Locale.add_thmss locale kind local_facts')
       
   179   end
       
   180 
   161 fun notes (Target {target, is_locale, ...}) kind facts lthy =
   181 fun notes (Target {target, is_locale, ...}) kind facts lthy =
   162   let
   182   let
   163     val thy = ProofContext.theory_of lthy;
   183     val thy = ProofContext.theory_of lthy;
   164     val facts' = facts
   184     val facts' = facts
   165       |> map (fn (a, bs) => (a, PureThy.burrow_fact (PureThy.name_multi
   185       |> map (fn (a, bs) => (a, PureThy.burrow_fact (PureThy.name_multi
   166           (Local_Theory.full_name lthy (fst a))) bs))
   186           (Local_Theory.full_name lthy (fst a))) bs))
   167       |> PureThy.map_facts (import_export_proof lthy);
   187       |> PureThy.map_facts (import_export_proof lthy);
   168     val local_facts = PureThy.map_facts #1 facts';
   188     val local_facts = PureThy.map_facts #1 facts';
   169     val global_facts = PureThy.map_facts #2 facts'
   189     val global_facts = PureThy.map_facts #2 facts';
   170       |> Attrib.map_facts (if is_locale then K I else Attrib.attribute_i thy);
       
   171   in
   190   in
   172     lthy
   191     lthy
   173     |> Local_Theory.theory (PureThy.note_thmss kind global_facts #> snd)
   192     |> (if is_locale then locale_notes target kind global_facts local_facts
   174     |> not is_locale ? Local_Theory.target (ProofContext.note_thmss kind global_facts #> snd)
   193         else theory_notes kind global_facts local_facts)
   175     |> is_locale ? Local_Theory.target (Locale.add_thmss target kind
       
   176          (Element.facts_map (Element.morph_ctxt (Local_Theory.target_morphism lthy)) local_facts))
       
   177     |> ProofContext.note_thmss kind (Attrib.map_facts (Attrib.attribute_i thy) local_facts)
   194     |> ProofContext.note_thmss kind (Attrib.map_facts (Attrib.attribute_i thy) local_facts)
   178   end;
   195   end;
   179 
   196 
   180 
   197 
   181 (* mixfix notation *)
   198 (* mixfix notation *)