src/HOL/Tools/Sledgehammer/sledgehammer_mash.ML
changeset 51029 211a9240b1e3
parent 51025 4acc150a321a
child 51032 69da236d7838
equal deleted inserted replaced
51028:7327a847f0c7 51029:211a9240b1e3
   465 
   465 
   466 fun mesh_facts _ max_facts [(_, (sels, unks))] =
   466 fun mesh_facts _ max_facts [(_, (sels, unks))] =
   467     map fst (take max_facts sels) @ take (max_facts - length sels) unks
   467     map fst (take max_facts sels) @ take (max_facts - length sels) unks
   468   | mesh_facts fact_eq max_facts mess =
   468   | mesh_facts fact_eq max_facts mess =
   469     let
   469     let
   470       val mess =
   470       val mess = mess |> map (apsnd (apfst (normalize_scores max_facts)))
   471         mess |> map (apsnd (apfst (normalize_scores max_facts #> `length)))
   471       fun score_in fact (global_weight, (sels, unks)) =
   472       fun score_in fact (global_weight, ((sel_len, sels), unks)) =
       
   473         let
   472         let
   474           fun score_at j =
   473           fun score_at j =
   475             case try (nth sels) j of
   474             case try (nth sels) j of
   476               SOME (_, score) => SOME (global_weight * score)
   475               SOME (_, score) => SOME (global_weight * score)
   477             | NONE => NONE
   476             | NONE => NONE
   482                    | _ => NONE)
   481                    | _ => NONE)
   483           | rank => score_at rank
   482           | rank => score_at rank
   484         end
   483         end
   485       fun weight_of fact = mess |> map_filter (score_in fact) |> scaled_avg
   484       fun weight_of fact = mess |> map_filter (score_in fact) |> scaled_avg
   486       val facts =
   485       val facts =
   487         fold (union fact_eq o map fst o take max_facts o snd o fst o snd) mess
   486         fold (union fact_eq o map fst o take max_facts o fst o snd) mess []
   488              []
       
   489     in
   487     in
   490       facts |> map (`weight_of) |> sort (int_ord o swap o pairself fst)
   488       facts |> map (`weight_of) |> sort (int_ord o swap o pairself fst)
   491             |> map snd |> take max_facts
   489             |> map snd |> take max_facts
   492     end
   490     end
   493 
   491