420 then (Vector.sub(thm_names,lno-1), t, []) :: stringify_deps thm_names deps_map lines |
420 then (Vector.sub(thm_names,lno-1), t, []) :: stringify_deps thm_names deps_map lines |
421 else let val lname = Int.toString (length deps_map) |
421 else let val lname = Int.toString (length deps_map) |
422 fun fix lno = if lno <= Vector.length thm_names |
422 fun fix lno = if lno <= Vector.length thm_names |
423 then SOME(Vector.sub(thm_names,lno-1)) |
423 then SOME(Vector.sub(thm_names,lno-1)) |
424 else AList.lookup op= deps_map lno; |
424 else AList.lookup op= deps_map lno; |
425 in (lname, t, List.mapPartial fix (distinct (op=) deps)) :: |
425 in (lname, t, map_filter fix (distinct (op=) deps)) :: |
426 stringify_deps thm_names ((lno,lname)::deps_map) lines |
426 stringify_deps thm_names ((lno,lname)::deps_map) lines |
427 end; |
427 end; |
428 |
428 |
429 val proofstart = "proof (neg_clausify)\n"; |
429 val proofstart = "proof (neg_clausify)\n"; |
430 |
430 |
449 if !Output.debugging then app (fn th => trace ("\nccl: " ^ string_of_thm ctxt th)) ccls |
449 if !Output.debugging then app (fn th => trace ("\nccl: " ^ string_of_thm ctxt th)) ccls |
450 else () |
450 else () |
451 val ilines = isar_lines ctxt (map prop_of ccls) (stringify_deps thm_names [] lines) |
451 val ilines = isar_lines ctxt (map prop_of ccls) (stringify_deps thm_names [] lines) |
452 val _ = trace "\ndecode_tstp_file: finishing\n" |
452 val _ = trace "\ndecode_tstp_file: finishing\n" |
453 in |
453 in |
454 isar_header (map #1 fixes) ^ String.concat ilines ^ "qed\n" |
454 isar_header (map #1 fixes) ^ implode ilines ^ "qed\n" |
455 end; |
455 end; |
456 |
456 |
457 |
457 |
458 (*=== EXTRACTING PROOF-TEXT === *) |
458 (*=== EXTRACTING PROOF-TEXT === *) |
459 |
459 |
502 let val toks = String.tokens (not o Char.isAlphaNum) |
502 let val toks = String.tokens (not o Char.isAlphaNum) |
503 fun inputno ("cnf"::ntok::"axiom"::_) = Int.fromString ntok |
503 fun inputno ("cnf"::ntok::"axiom"::_) = Int.fromString ntok |
504 | inputno ("cnf"::ntok::"negated"::"conjecture"::_) = Int.fromString ntok |
504 | inputno ("cnf"::ntok::"negated"::"conjecture"::_) = Int.fromString ntok |
505 | inputno _ = NONE |
505 | inputno _ = NONE |
506 val lines = split_lines proofextract |
506 val lines = split_lines proofextract |
507 in List.mapPartial (inputno o toks) lines end |
507 in map_filter (inputno o toks) lines end |
508 (*String contains multiple lines. We want those of the form |
508 (*String contains multiple lines. We want those of the form |
509 "253[0:Inp] et cetera..." |
509 "253[0:Inp] et cetera..." |
510 A list consisting of the first number in each line is returned. *) |
510 A list consisting of the first number in each line is returned. *) |
511 | get_step_nums true proofextract = |
511 | get_step_nums true proofextract = |
512 let val toks = String.tokens (not o Char.isAlphaNum) |
512 let val toks = String.tokens (not o Char.isAlphaNum) |
513 fun inputno (ntok::"0"::"Inp"::_) = Int.fromString ntok |
513 fun inputno (ntok::"0"::"Inp"::_) = Int.fromString ntok |
514 | inputno _ = NONE |
514 | inputno _ = NONE |
515 val lines = split_lines proofextract |
515 val lines = split_lines proofextract |
516 in List.mapPartial (inputno o toks) lines end |
516 in map_filter (inputno o toks) lines end |
517 |
517 |
518 (*extracting lemmas from tstp-output between the lines from above*) |
518 (*extracting lemmas from tstp-output between the lines from above*) |
519 fun extract_lemmas get_step_nums (proof, thm_names, conj_count, _, _, _) = |
519 fun extract_lemmas get_step_nums (proof, thm_names, conj_count, _, _, _) = |
520 let |
520 let |
521 (* get the names of axioms from their numbers*) |
521 (* get the names of axioms from their numbers*) |