134 if heading = factsN then (heading, order_facts ord lines) :: problem |
134 if heading = factsN then (heading, order_facts ord lines) :: problem |
135 else (heading, lines) :: order_problem_facts ord problem |
135 else (heading, lines) :: order_problem_facts ord problem |
136 |
136 |
137 (* A fairly random selection of types used for monomorphizing. *) |
137 (* A fairly random selection of types used for monomorphizing. *) |
138 val ground_types = |
138 val ground_types = |
139 [@{typ nat}, HOLogic.intT, HOLogic.realT, @{typ "nat => bool"}, @{typ bool}, |
139 [\<^typ>\<open>nat\<close>, HOLogic.intT, HOLogic.realT, \<^typ>\<open>nat => bool\<close>, \<^typ>\<open>bool\<close>, |
140 @{typ unit}] |
140 \<^typ>\<open>unit\<close>] |
141 |
141 |
142 fun ground_type_of_tvar _ [] tvar = raise TYPE ("ground_type_of_tvar", [TVar tvar], []) |
142 fun ground_type_of_tvar _ [] tvar = raise TYPE ("ground_type_of_tvar", [TVar tvar], []) |
143 | ground_type_of_tvar thy (T :: Ts) tvar = |
143 | ground_type_of_tvar thy (T :: Ts) tvar = |
144 if can (Sign.typ_match thy (TVar tvar, T)) Vartab.empty then T |
144 if can (Sign.typ_match thy (TVar tvar, T)) Vartab.empty then T |
145 else ground_type_of_tvar thy Ts tvar |
145 else ground_type_of_tvar thy Ts tvar |
146 |
146 |
147 fun monomorphize_term ctxt t = |
147 fun monomorphize_term ctxt t = |
148 let val thy = Proof_Context.theory_of ctxt in |
148 let val thy = Proof_Context.theory_of ctxt in |
149 t |> map_types (map_type_tvar (ground_type_of_tvar thy ground_types)) |
149 t |> map_types (map_type_tvar (ground_type_of_tvar thy ground_types)) |
150 handle TYPE _ => @{prop True} |
150 handle TYPE _ => \<^prop>\<open>True\<close> |
151 end |
151 end |
152 |
152 |
153 fun heading_sort_key heading = |
153 fun heading_sort_key heading = |
154 if String.isPrefix factsN heading then "_" ^ heading else heading |
154 if String.isPrefix factsN heading then "_" ^ heading else heading |
155 |
155 |
168 val problem = |
168 val problem = |
169 facts |
169 facts |
170 |> map (fn ((_, loc), th) => |
170 |> map (fn ((_, loc), th) => |
171 ((Thm.get_name_hint th, loc), th |> Thm.prop_of |> mono ? monomorphize_term ctxt)) |
171 ((Thm.get_name_hint th, loc), th |> Thm.prop_of |> mono ? monomorphize_term ctxt)) |
172 |> generate_atp_problem ctxt true format Axiom type_enc Exporter combsN false false true [] |
172 |> generate_atp_problem ctxt true format Axiom type_enc Exporter combsN false false true [] |
173 @{prop False} |
173 \<^prop>\<open>False\<close> |
174 |> #1 |> sort_by (heading_sort_key o fst) |
174 |> #1 |> sort_by (heading_sort_key o fst) |
175 val prelude = fst (split_last problem) |
175 val prelude = fst (split_last problem) |
176 val name_tabs = Sledgehammer_Fact.build_name_tables Thm.get_name_hint facts |
176 val name_tabs = Sledgehammer_Fact.build_name_tables Thm.get_name_hint facts |
177 val infers = |
177 val infers = |
178 if infer_policy = No_Inferences then |
178 if infer_policy = No_Inferences then |