src/HOL/Tools/ATP/atp_proof_reconstruct.ML
changeset 74379 9ea507f63bcb
parent 74050 bed899f14df7
child 75048 e926618f9474
equal deleted inserted replaced
74378:bb25ea271b15 74379:9ea507f63bcb
   125     (case (u, v) of
   125     (case (u, v) of
   126       (Const (\<^const_name>\<open>True\<close>, _), _) => v
   126       (Const (\<^const_name>\<open>True\<close>, _), _) => v
   127     | (u, Const (\<^const_name>\<open>True\<close>, _)) => u
   127     | (u, Const (\<^const_name>\<open>True\<close>, _)) => u
   128     | (Const (\<^const_name>\<open>False\<close>, _), v) => s_not v
   128     | (Const (\<^const_name>\<open>False\<close>, _), v) => s_not v
   129     | (u, Const (\<^const_name>\<open>False\<close>, _)) => s_not u
   129     | (u, Const (\<^const_name>\<open>False\<close>, _)) => s_not u
   130     | _ => if u aconv v then \<^const>\<open>True\<close> else t $ simplify_bool u $ simplify_bool v)
   130     | _ => if u aconv v then \<^Const>\<open>True\<close> else t $ simplify_bool u $ simplify_bool v)
   131   | simplify_bool (t $ u) = simplify_bool t $ simplify_bool u
   131   | simplify_bool (t $ u) = simplify_bool t $ simplify_bool u
   132   | simplify_bool (Abs (s, T, t)) = Abs (s, T, simplify_bool t)
   132   | simplify_bool (Abs (s, T, t)) = Abs (s, T, simplify_bool t)
   133   | simplify_bool t = t
   133   | simplify_bool t = t
   134 
   134 
   135 fun single_letter upper s =
   135 fun single_letter upper s =
   349         ATerm ((s, tys), us) =>
   349         ATerm ((s, tys), us) =>
   350         if s = "" (* special marker generated on parse error *) then
   350         if s = "" (* special marker generated on parse error *) then
   351           error "Isar proof reconstruction failed because the ATP proof contains unparsable \
   351           error "Isar proof reconstruction failed because the ATP proof contains unparsable \
   352             \material"
   352             \material"
   353         else if String.isPrefix native_type_prefix s then
   353         else if String.isPrefix native_type_prefix s then
   354           \<^const>\<open>True\<close> (* ignore TPTP type information (needed?) *)
   354           \<^Const>\<open>True\<close> (* ignore TPTP type information (needed?) *)
   355         else if s = tptp_equal then
   355         else if s = tptp_equal then
   356           list_comb (Const (\<^const_name>\<open>HOL.eq\<close>, Type_Infer.anyT \<^sort>\<open>type\<close>),
   356           list_comb (Const (\<^const_name>\<open>HOL.eq\<close>, Type_Infer.anyT \<^sort>\<open>type\<close>),
   357             map (do_term [] NONE) us)
   357             map (do_term [] NONE) us)
   358         else
   358         else
   359           (case unprefix_and_unascii const_prefix s of
   359           (case unprefix_and_unascii const_prefix s of
   370                   do_term (extra_t :: extra_ts)
   370                   do_term (extra_t :: extra_ts)
   371                     (case opt_T of SOME T => SOME (slack_fastype_of extra_t --> T) | NONE => NONE)
   371                     (case opt_T of SOME T => SOME (slack_fastype_of extra_t --> T) | NONE => NONE)
   372                     (nth us (length us - 2))
   372                     (nth us (length us - 2))
   373                 end
   373                 end
   374               else if s' = type_guard_name then
   374               else if s' = type_guard_name then
   375                 \<^const>\<open>True\<close> (* ignore type predicates *)
   375                 \<^Const>\<open>True\<close> (* ignore type predicates *)
   376               else
   376               else
   377                 let
   377                 let
   378                   val new_skolem = String.isPrefix new_skolem_const_prefix s''
   378                   val new_skolem = String.isPrefix new_skolem_const_prefix s''
   379                   val num_ty_args = length us - the_default 0 (Symtab.lookup sym_tab s)
   379                   val num_ty_args = length us - the_default 0 (Symtab.lookup sym_tab s)
   380                   val (type_us, term_us) = chop num_ty_args us |>> append mangled_us
   380                   val (type_us, term_us) = chop num_ty_args us |>> append mangled_us
   434     else error "Unsupported Isar reconstruction"
   434     else error "Unsupported Isar reconstruction"
   435 
   435 
   436 fun term_of_atom ctxt format type_enc textual sym_tab pos (u as ATerm ((s, _), _)) =
   436 fun term_of_atom ctxt format type_enc textual sym_tab pos (u as ATerm ((s, _), _)) =
   437   if String.isPrefix class_prefix s then
   437   if String.isPrefix class_prefix s then
   438     add_type_constraint pos (type_constraint_of_term ctxt u)
   438     add_type_constraint pos (type_constraint_of_term ctxt u)
   439     #> pair \<^const>\<open>True\<close>
   439     #> pair \<^Const>\<open>True\<close>
   440   else
   440   else
   441     pair (term_of_atp ctxt format type_enc textual sym_tab (SOME \<^typ>\<open>bool\<close>) u)
   441     pair (term_of_atp ctxt format type_enc textual sym_tab (SOME \<^typ>\<open>bool\<close>) u)
   442 
   442 
   443 (* Update schematic type variables with detected sort constraints. It's not
   443 (* Update schematic type variables with detected sort constraints. It's not
   444    totally clear whether this code is necessary. *)
   444    totally clear whether this code is necessary. *)
   615 
   615 
   616 val waldmeister_conjecture_num = "1.0.0.0"
   616 val waldmeister_conjecture_num = "1.0.0.0"
   617 
   617 
   618 fun repair_waldmeister_endgame proof =
   618 fun repair_waldmeister_endgame proof =
   619   let
   619   let
   620     fun repair_tail (name, _, \<^const>\<open>Trueprop\<close> $ t, rule, deps) =
   620     fun repair_tail (name, _, \<^Const>\<open>Trueprop for t\<close>, rule, deps) =
   621       (name, Negated_Conjecture, \<^const>\<open>Trueprop\<close> $ s_not t, rule, deps)
   621       (name, Negated_Conjecture, \<^Const>\<open>Trueprop for \<open>s_not t\<close>\<close>, rule, deps)
   622     fun repair_body [] = []
   622     fun repair_body [] = []
   623       | repair_body ((line as ((num, _), _, _, _, _)) :: lines) =
   623       | repair_body ((line as ((num, _), _, _, _, _)) :: lines) =
   624         if num = waldmeister_conjecture_num then map repair_tail (line :: lines)
   624         if num = waldmeister_conjecture_num then map repair_tail (line :: lines)
   625         else line :: repair_body lines
   625         else line :: repair_body lines
   626   in
   626   in