src/Pure/Thy/export_theory.ML
changeset 70976 d86798eddc14
parent 70975 19818f99b4ae
child 70979 7abe5abb4c05
equal deleted inserted replaced
70975:19818f99b4ae 70976:d86798eddc14
   252 
   252 
   253     val clean_thm = Thm.check_hyps (Context.Theory thy) #> Thm.strip_shyps;
   253     val clean_thm = Thm.check_hyps (Context.Theory thy) #> Thm.strip_shyps;
   254 
   254 
   255     val lookup_thm_id = Global_Theory.lookup_thm_id thy;
   255     val lookup_thm_id = Global_Theory.lookup_thm_id thy;
   256 
   256 
   257     fun proof_boxes_of thm thm_id =
   257     fun proof_boxes thm thm_id =
   258       (Thm_Deps.thm_boxes
   258       let
   259         {included = fn thm_id' => #serial thm_id = #serial thm_id',
   259         val selection =
   260          excluded = is_some o lookup_thm_id} [thm]) @ [thm_id];
   260          {included = fn thm_id' => #serial thm_id = #serial thm_id',
       
   261           excluded = is_some o lookup_thm_id};
       
   262         val boxes =
       
   263           map (Proofterm.thm_header_id o #1) (Proofterm.proof_boxes selection [Thm.proof_of thm])
       
   264             handle Proofterm.MIN_PROOF () => Thm_Deps.thm_boxes selection [thm]
       
   265      in boxes @ [thm_id] end;
   261 
   266 
   262     fun expand_name thm_id (header: Proofterm.thm_header) =
   267     fun expand_name thm_id (header: Proofterm.thm_header) =
   263       if #serial header = #serial thm_id then ""
   268       if #serial header = #serial thm_id then ""
   264       else
   269       else
   265         (case lookup_thm_id (Proofterm.thm_header_id header) of
   270         (case lookup_thm_id (Proofterm.thm_header_id header) of
   275 
   280 
   276     fun encode_thm thm_id raw_thm =
   281     fun encode_thm thm_id raw_thm =
   277       let
   282       let
   278         val deps = map (Thm_Name.print o #2) (Thm_Deps.thm_deps thy [raw_thm]);
   283         val deps = map (Thm_Name.print o #2) (Thm_Deps.thm_deps thy [raw_thm]);
   279         val thm = clean_thm (Thm.unconstrainT raw_thm);
   284         val thm = clean_thm (Thm.unconstrainT raw_thm);
   280         val boxes = proof_boxes_of thm thm_id;
   285         val boxes = proof_boxes thm thm_id;
   281 
   286 
   282         val proof0 =
   287         val proof0 =
   283           if export_standard_proofs then
   288           if export_standard_proofs then
   284             Thm.standard_proof_of {full = true, expand_name = SOME o expand_name thm_id} thm
   289             Thm.standard_proof_of {full = true, expand_name = SOME o expand_name thm_id} thm
   285           else if Proofterm.export_enabled () then Thm.reconstruct_proof_of thm
   290           else if Proofterm.export_enabled () then Thm.reconstruct_proof_of thm