src/HOL/Tools/ATP/atp_problem_generate.ML
changeset 47991 3eb598b044ad
parent 47981 df35a8dd6368
child 48004 989a34fa72b3
equal deleted inserted replaced
47990:7a642e5c272c 47991:3eb598b044ad
  1245       | freeze (Var ((s, i), T)) =
  1245       | freeze (Var ((s, i), T)) =
  1246         Free (atp_weak_prefix ^ s ^ "_" ^ string_of_int i, T)
  1246         Free (atp_weak_prefix ^ s ^ "_" ^ string_of_int i, T)
  1247       | freeze t = t
  1247       | freeze t = t
  1248   in t |> exists_subterm is_Var t ? freeze end
  1248   in t |> exists_subterm is_Var t ? freeze end
  1249 
  1249 
  1250 fun unextensionalize_def t =
       
  1251   case t of
       
  1252     @{const Trueprop} $ (Const (@{const_name HOL.eq}, _) $ lhs $ rhs) =>
       
  1253     (case strip_comb lhs of
       
  1254        (c as Const (_, T), args) =>
       
  1255        if forall is_Var args andalso not (has_duplicates (op =) args) then
       
  1256          @{const Trueprop}
       
  1257          $ (Const (@{const_name HOL.eq}, T --> T --> @{typ bool})
       
  1258             $ c $ fold_rev lambda args rhs)
       
  1259        else
       
  1260          t
       
  1261      | _ => t)
       
  1262   | _ => t
       
  1263 
       
  1264 fun presimp_prop ctxt type_enc t =
  1250 fun presimp_prop ctxt type_enc t =
  1265   let
  1251   let
  1266     val thy = Proof_Context.theory_of ctxt
  1252     val thy = Proof_Context.theory_of ctxt
  1267     val t = t |> Envir.beta_eta_contract
  1253     val t = t |> Envir.beta_eta_contract
  1268               |> transform_elim_prop
  1254               |> transform_elim_prop
  1294   in
  1280   in
  1295     {name = name, stature = stature, role = role, iformula = iformula,
  1281     {name = name, stature = stature, role = role, iformula = iformula,
  1296      atomic_types = atomic_Ts}
  1282      atomic_types = atomic_Ts}
  1297   end
  1283   end
  1298 
  1284 
  1299 fun is_legitimate_thf_def (Const (@{const_name HOL.eq}, _) $ t $ u) =
       
  1300     (is_Const t orelse is_Free t) andalso
       
  1301     not (exists_subterm (curry (op =) t) u)
       
  1302   | is_legitimate_thf_def _ = false
       
  1303 
       
  1304 fun make_fact ctxt format type_enc iff_for_eq
  1285 fun make_fact ctxt format type_enc iff_for_eq
  1305               ((name, stature as (_, status)), t) =
  1286               ((name, stature as (_, status)), t) =
  1306   let
  1287   let
  1307     val role =
  1288     val role =
  1308       if is_type_enc_higher_order type_enc andalso status = Def andalso
  1289       if is_type_enc_higher_order type_enc andalso status = Def andalso
  1309          is_legitimate_thf_def t then
  1290          is_legitimate_tptp_def t then
  1310         Definition
  1291         Definition
  1311       else
  1292       else
  1312         Axiom
  1293         Axiom
  1313   in
  1294   in
  1314     case t |> make_formula ctxt format type_enc iff_for_eq name stature role of
  1295     case t |> make_formula ctxt format type_enc iff_for_eq name stature role of
  1327 fun make_conjecture ctxt format type_enc =
  1308 fun make_conjecture ctxt format type_enc =
  1328   map (fn ((name, stature), (role, t)) =>
  1309   map (fn ((name, stature), (role, t)) =>
  1329           let
  1310           let
  1330             val role =
  1311             val role =
  1331               if is_type_enc_higher_order type_enc andalso
  1312               if is_type_enc_higher_order type_enc andalso
  1332                  role <> Conjecture andalso is_legitimate_thf_def t then
  1313                  role <> Conjecture andalso is_legitimate_tptp_def t then
  1333                 Definition
  1314                 Definition
  1334               else
  1315               else
  1335                 role
  1316                 role
  1336           in
  1317           in
  1337             t |> role = Conjecture ? s_not
  1318             t |> role = Conjecture ? s_not