src/HOL/Tools/Mirabelle/mirabelle.ML
changeset 80306 c2537860ccf8
parent 80295 8a9588ffc133
equal deleted inserted replaced
80305:95b51df1382e 80306:c2537860ccf8
   303     fun app n (PBody {thms, ...}) = thms |> fold (fn (i, thm_node) =>
   303     fun app n (PBody {thms, ...}) = thms |> fold (fn (i, thm_node) =>
   304       fn (x, seen) =>
   304       fn (x, seen) =>
   305         if Inttab.defined seen i then (x, seen)
   305         if Inttab.defined seen i then (x, seen)
   306         else
   306         else
   307           let
   307           let
   308             val name = Thm_Name.short (Proofterm.thm_node_name thm_node);
   308             val name = Proofterm.thm_node_name thm_node;
   309             val prop = Proofterm.thm_node_prop thm_node;
   309             val prop = Proofterm.thm_node_prop thm_node;
   310             val body = Future.join (Proofterm.thm_node_body thm_node);
   310             val body = Future.join (Proofterm.thm_node_body thm_node);
   311             val (x', seen') =
   311             val (x', seen') =
   312               app (n + (if name = "" then 0 else 1)) body
   312               app (n + (if Thm_Name.is_empty name then 0 else 1)) body
   313                 (x, Inttab.update (i, ()) seen);
   313                 (x, Inttab.update (i, ()) seen);
   314         in (x' |> n = 0 ? f (name, prop, body), seen') end);
   314         in (x' |> n = 0 ? f (name, prop, body), seen') end);
   315   in fn bodies => fn x => #1 (fold (app 0) bodies (x, Inttab.empty)) end;
   315   in fn bodies => fn x => #1 (fold (app 0) bodies (x, Inttab.empty)) end;
   316 
   316 
   317 in
   317 in
   318 
   318 
   319 fun theorems_in_proof_term thy thm =
   319 fun theorems_in_proof_term thy thm =
   320   let
   320   let
   321     val all_thms = Global_Theory.all_thms_of thy true;
   321     val all_thms = Global_Theory.all_thms_of thy true;
   322     fun collect (s, _, _) = if s <> "" then insert (op =) s else I;
   322     fun collect (name, _, _) = if Thm_Name.is_empty name then I else insert (op =) name;
   323     fun member_of xs (x, y) = if member (op =) xs x then SOME y else NONE;
   323     fun member_of xs (x, y) = if member (op =) xs x then SOME y else NONE;
   324     fun resolve_thms names = map_filter (member_of names) all_thms;
   324     fun resolve_thms names = map_filter (member_of names) all_thms;
   325   in resolve_thms (fold_body_thms collect [Thm.proof_body_of thm] []) end;
   325   in resolve_thms (fold_body_thms collect [Thm.proof_body_of thm] []) end;
   326 
   326 
   327 end;
   327 end;