363 |
363 |
364 (* No "real" literals means only type information (tfree_tcs, clsrel, or |
364 (* No "real" literals means only type information (tfree_tcs, clsrel, or |
365 clsarity). *) |
365 clsarity). *) |
366 fun is_only_type_information t = t aconv @{term True} |
366 fun is_only_type_information t = t aconv @{term True} |
367 |
367 |
|
368 fun s_maybe_not role = role <> Conjecture ? s_not |
|
369 |
368 fun is_same_inference _ (Definition_Step _) = false |
370 fun is_same_inference _ (Definition_Step _) = false |
369 | is_same_inference t (Inference_Step (_, _, t', _, _)) = t aconv t' |
371 | is_same_inference (role, t) (Inference_Step (_, role', t', _, _)) = |
|
372 s_maybe_not role t aconv s_maybe_not role' t' |
370 |
373 |
371 (* Discard facts; consolidate adjacent lines that prove the same formula, since |
374 (* Discard facts; consolidate adjacent lines that prove the same formula, since |
372 they differ only in type information.*) |
375 they differ only in type information.*) |
373 fun add_line _ (line as Definition_Step _) lines = line :: lines |
376 fun add_line _ (line as Definition_Step _) lines = line :: lines |
374 | add_line fact_names (Inference_Step (name as (_, ss), role, t, rule, [])) |
377 | add_line fact_names (Inference_Step (name as (_, ss), role, t, rule, [])) |
375 lines = |
378 lines = |
376 (* No dependencies: fact, conjecture, or (for Vampire) internal facts or |
379 (* No dependencies: fact, conjecture, or (for Vampire) internal facts or |
377 definitions. *) |
380 definitions. *) |
378 if is_fact fact_names ss then |
381 if is_conjecture ss then |
|
382 Inference_Step (name, role, t, rule, []) :: lines |
|
383 else if is_fact fact_names ss then |
379 (* Facts are not proof lines. *) |
384 (* Facts are not proof lines. *) |
380 if is_only_type_information t then |
385 if is_only_type_information t then |
381 map (replace_dependencies_in_line (name, [])) lines |
386 map (replace_dependencies_in_line (name, [])) lines |
382 (* Is there a repetition? If so, replace later line by earlier one. *) |
387 else |
383 else case take_prefix (not o is_same_inference t) lines of |
388 lines |
384 (_, []) => lines (* no repetition of proof line *) |
|
385 | (pre, Inference_Step (name', _, _, _, _) :: post) => |
|
386 pre @ map (replace_dependencies_in_line (name', [name])) post |
|
387 | _ => raise Fail "unexpected inference" |
|
388 else if is_conjecture ss then |
|
389 Inference_Step (name, role, t, rule, []) :: lines |
|
390 else |
389 else |
391 map (replace_dependencies_in_line (name, [])) lines |
390 map (replace_dependencies_in_line (name, [])) lines |
392 | add_line _ (line as Inference_Step (name, role, t, rule, deps)) lines = |
391 | add_line _ (line as Inference_Step (name, role, t, rule, deps)) lines = |
393 (* Type information will be deleted later; skip repetition test. *) |
392 (* Type information will be deleted later; skip repetition test. *) |
394 if is_only_type_information t then |
393 if is_only_type_information t then |
395 line :: lines |
394 line :: lines |
396 (* Is there a repetition? If so, replace later line by earlier one. *) |
395 (* Is there a repetition? If so, replace later line by earlier one. *) |
397 else case take_prefix (not o is_same_inference t) lines of |
396 else case take_prefix (not o is_same_inference (role, t)) lines of |
398 (* FIXME: Doesn't this code risk conflating proofs involving different |
397 (* FIXME: Doesn't this code risk conflating proofs involving different |
399 types? *) |
398 types? *) |
400 (_, []) => line :: lines |
399 (_, []) => line :: lines |
401 | (pre, Inference_Step (name', _, _, _, _) :: post) => |
400 | (pre, Inference_Step (name', _, _, _, _) :: post) => |
402 line :: pre @ map (replace_dependencies_in_line (name', [name])) post |
401 line :: pre @ map (replace_dependencies_in_line (name', [name])) post |
404 |
403 |
405 val waldmeister_conjecture_num = "1.0.0.0" |
404 val waldmeister_conjecture_num = "1.0.0.0" |
406 |
405 |
407 val repair_waldmeister_endgame = |
406 val repair_waldmeister_endgame = |
408 let |
407 let |
409 fun do_tail (Inference_Step (name, role, t, rule, deps)) = |
408 fun do_tail (Inference_Step (name, _, t, rule, deps)) = |
410 Inference_Step (name, role, s_not t, rule, deps) |
409 Inference_Step (name, Negated_Conjecture, s_not t, rule, deps) |
411 | do_tail line = line |
410 | do_tail line = line |
412 fun do_body [] = [] |
411 fun do_body [] = [] |
413 | do_body ((line as Inference_Step ((num, _), _, _, _, _)) :: lines) = |
412 | do_body ((line as Inference_Step ((num, _), _, _, _, _)) :: lines) = |
414 if num = waldmeister_conjecture_num then map do_tail (line :: lines) |
413 if num = waldmeister_conjecture_num then map do_tail (line :: lines) |
415 else line :: do_body lines |
414 else line :: do_body lines |
683 Symtab.empty |
682 Symtab.empty |
684 |> fold (fn Definition_Step _ => I (* FIXME *) |
683 |> fold (fn Definition_Step _ => I (* FIXME *) |
685 | Inference_Step (name as (s, ss), role, t, rule, _) => |
684 | Inference_Step (name as (s, ss), role, t, rule, _) => |
686 Symtab.update_new (s, (rule, |
685 Symtab.update_new (s, (rule, |
687 t |> (if member (op = o apsnd fst) tainted s then |
686 t |> (if member (op = o apsnd fst) tainted s then |
688 (role <> Conjecture ? s_not) |
687 s_maybe_not role |
689 #> fold exists_of (map Var (Term.add_vars t [])) |
688 #> fold exists_of (map Var (Term.add_vars t [])) |
690 else |
689 else |
691 I)))) |
690 I)))) |
692 atp_proof |
691 atp_proof |
693 fun is_clause_skolemize_rule [(s, _)] = |
692 fun is_clause_skolemize_rule [(s, _)] = |