336 fun overlord_file_location_for_prover prover = |
336 fun overlord_file_location_for_prover prover = |
337 (getenv "ISABELLE_HOME_USER", "prob_" ^ prover) |
337 (getenv "ISABELLE_HOME_USER", "prob_" ^ prover) |
338 |
338 |
339 |
339 |
340 (* generic TPTP-based ATPs *) |
340 (* generic TPTP-based ATPs *) |
|
341 |
|
342 (* Too general means, positive equality literal with a variable X as one |
|
343 operand, when X does not occur properly in the other operand. This rules out |
|
344 clearly inconsistent facts such as X = a | X = b, though it by no means |
|
345 guarantees soundness. *) |
|
346 |
|
347 (* Unwanted equalities are those between a (bound or schematic) variable that |
|
348 does not properly occur in the second operand. *) |
|
349 val is_exhaustive_finite = |
|
350 let |
|
351 fun is_bad_equal (Var z) t = |
|
352 not (exists_subterm (fn Var z' => z = z' | _ => false) t) |
|
353 | is_bad_equal (Bound j) t = not (loose_bvar1 (t, j)) |
|
354 | is_bad_equal _ _ = false |
|
355 fun do_equals t1 t2 = is_bad_equal t1 t2 orelse is_bad_equal t2 t1 |
|
356 fun do_formula pos t = |
|
357 case (pos, t) of |
|
358 (_, @{const Trueprop} $ t1) => do_formula pos t1 |
|
359 | (true, Const (@{const_name all}, _) $ Abs (_, _, t')) => |
|
360 do_formula pos t' |
|
361 | (true, Const (@{const_name All}, _) $ Abs (_, _, t')) => |
|
362 do_formula pos t' |
|
363 | (false, Const (@{const_name Ex}, _) $ Abs (_, _, t')) => |
|
364 do_formula pos t' |
|
365 | (_, @{const "==>"} $ t1 $ t2) => |
|
366 do_formula (not pos) t1 andalso |
|
367 (t2 = @{prop False} orelse do_formula pos t2) |
|
368 | (_, @{const HOL.implies} $ t1 $ t2) => |
|
369 do_formula (not pos) t1 andalso |
|
370 (t2 = @{const False} orelse do_formula pos t2) |
|
371 | (_, @{const Not} $ t1) => do_formula (not pos) t1 |
|
372 | (true, @{const HOL.disj} $ t1 $ t2) => forall (do_formula pos) [t1, t2] |
|
373 | (false, @{const HOL.conj} $ t1 $ t2) => forall (do_formula pos) [t1, t2] |
|
374 | (true, Const (@{const_name HOL.eq}, _) $ t1 $ t2) => do_equals t1 t2 |
|
375 | (true, Const (@{const_name "=="}, _) $ t1 $ t2) => do_equals t1 t2 |
|
376 | _ => false |
|
377 in do_formula true end |
|
378 |
|
379 fun has_bound_or_var_of_type pred = |
|
380 exists_subterm (fn Var (_, T as Type _) => pred T |
|
381 | Abs (_, T as Type _, _) => pred T |
|
382 | _ => false) |
|
383 |
|
384 (* Facts are forbidden to contain variables of these types. The typical reason |
|
385 is that they lead to unsoundness. Note that "unit" satisfies numerous |
|
386 equations like "?x = ()". The resulting clauses will have no type constraint, |
|
387 yielding false proofs. Even "bool" leads to many unsound proofs, though only |
|
388 for higher-order problems. *) |
|
389 |
|
390 (* Facts containing variables of type "unit" or "bool" or of the form |
|
391 "ALL x. x = A | x = B | x = C" are likely to lead to unsound proofs if types |
|
392 are omitted. *) |
|
393 fun is_dangerous_term ctxt = |
|
394 transform_elim_term |
|
395 #> (has_bound_or_var_of_type (is_type_surely_finite ctxt) orf |
|
396 is_exhaustive_finite) |
341 |
397 |
342 fun int_opt_add (SOME m) (SOME n) = SOME (m + n) |
398 fun int_opt_add (SOME m) (SOME n) = SOME (m + n) |
343 | int_opt_add _ _ = NONE |
399 | int_opt_add _ _ = NONE |
344 |
400 |
345 val atp_blacklist_max_iters = 10 |
401 val atp_blacklist_max_iters = 10 |
446 val (format, type_sys) = |
502 val (format, type_sys) = |
447 determine_format_and_type_sys best_type_systems formats type_sys |
503 determine_format_and_type_sys best_type_systems formats type_sys |
448 val fairly_sound = is_type_sys_fairly_sound type_sys |
504 val fairly_sound = is_type_sys_fairly_sound type_sys |
449 val facts = |
505 val facts = |
450 facts |> not fairly_sound |
506 facts |> not fairly_sound |
451 ? filter_out (is_dangerous_term o prop_of o snd |
507 ? filter_out (is_dangerous_term ctxt o prop_of o snd |
452 o untranslated_fact) |
508 o untranslated_fact) |
453 |> take num_facts |
509 |> take num_facts |
454 |> not (null blacklist) |
510 |> not (null blacklist) |
455 ? filter_out (member (op =) blacklist o fst |
511 ? filter_out (member (op =) blacklist o fst |
456 o untranslated_fact) |
512 o untranslated_fact) |