src/HOL/Tools/Sledgehammer/sledgehammer_proof_methods.ML
author blanchet
Thu, 13 Mar 2014 13:18:14 +0100
changeset 56093 4eeb73a1feec
parent 56081 72fad75baf7e
child 56852 b38c5b9cf590
permissions -rw-r--r--
simplified preplaying information
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55287
ffa306239316 renamed ML file
blanchet
parents: 55286
diff changeset
     1
(*  Title:      HOL/Tools/Sledgehammer/sledgehammer_proof_methods.ML
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     2
    Author:     Jasmin Blanchette, TU Muenchen
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     3
    Author:     Steffen Juilf Smolka, TU Muenchen
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     4
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     5
Reconstructors.
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     6
*)
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     7
55287
ffa306239316 renamed ML file
blanchet
parents: 55286
diff changeset
     8
signature SLEDGEHAMMER_PROOF_METHODS =
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
     9
sig
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    10
  type stature = ATP_Problem_Generate.stature
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    11
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    12
  datatype proof_method =
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    13
    Metis_Method of string option * string option |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    14
    Meson_Method |
56081
72fad75baf7e integrate SMT2 with Sledgehammer
blanchet
parents: 55452
diff changeset
    15
    SMT2_Method |
55323
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    16
    Blast_Method |
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    17
    Simp_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    18
    Simp_Size_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    19
    Auto_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    20
    Fastforce_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    21
    Force_Method |
55323
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    22
    Linarith_Method |
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    23
    Presburger_Method |
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    24
    Algebra_Method
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    25
54824
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    26
  datatype play_outcome =
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    27
    Played of Time.time |
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    28
    Play_Timed_Out of Time.time |
56093
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
    29
    Play_Failed
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    30
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    31
  type minimize_command = string list -> string
54824
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    32
  type one_line_params =
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    33
    (proof_method * play_outcome) * string * (string * stature) list * minimize_command * int * int
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    34
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    35
  val string_of_proof_method : proof_method -> string
55452
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    36
  val tac_of_proof_method : Proof.context -> bool -> thm list * thm list -> proof_method -> int ->
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    37
    tactic
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
    38
  val string_of_play_outcome : play_outcome -> string
55269
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
    39
  val play_outcome_ord : play_outcome * play_outcome -> order
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
    40
  val one_line_proof_text : int -> one_line_params -> string
54495
237d5be57277 refactored
blanchet
parents: 52590
diff changeset
    41
end;
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    42
55287
ffa306239316 renamed ML file
blanchet
parents: 55286
diff changeset
    43
structure Sledgehammer_Proof_Methods : SLEDGEHAMMER_PROOF_METHODS =
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    44
struct
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    45
54828
b2271ad695db don't do 'isar_try0' if preplaying is off
blanchet
parents: 54824
diff changeset
    46
open ATP_Util
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    47
open ATP_Problem_Generate
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
    48
open ATP_Proof_Reconstruct
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    49
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    50
datatype proof_method =
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    51
  Metis_Method of string option * string option |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    52
  Meson_Method |
56081
72fad75baf7e integrate SMT2 with Sledgehammer
blanchet
parents: 55452
diff changeset
    53
  SMT2_Method |
55323
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    54
  Blast_Method |
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    55
  Simp_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    56
  Simp_Size_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    57
  Auto_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    58
  Fastforce_Method |
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    59
  Force_Method |
55323
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    60
  Linarith_Method |
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    61
  Presburger_Method |
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    62
  Algebra_Method
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    63
54824
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    64
datatype play_outcome =
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    65
  Played of Time.time |
4e58a38b330b refactored preplaying outcome data structure
blanchet
parents: 54823
diff changeset
    66
  Play_Timed_Out of Time.time |
56093
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
    67
  Play_Failed
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
    68
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
    69
type minimize_command = string list -> string
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
    70
type one_line_params =
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    71
  (proof_method * play_outcome) * string * (string * stature) list * minimize_command * int * int
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
    72
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    73
fun string_of_proof_method meth =
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    74
  (case meth of
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    75
    Metis_Method (NONE, NONE) => "metis"
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    76
  | Metis_Method (type_enc_opt, lam_trans_opt) =>
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    77
    "metis (" ^ commas (map_filter I [type_enc_opt, lam_trans_opt]) ^ ")"
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    78
  | Meson_Method => "meson"
56081
72fad75baf7e integrate SMT2 with Sledgehammer
blanchet
parents: 55452
diff changeset
    79
  | SMT2_Method => "smt2"
55323
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    80
  | Blast_Method => "blast"
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    81
  | Simp_Method => "simp"
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    82
  | Simp_Size_Method => "simp add: size_ne_size_imp_ne"
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    83
  | Auto_Method => "auto"
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    84
  | Fastforce_Method => "fastforce"
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    85
  | Force_Method => "force"
55323
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    86
  | Linarith_Method => "linarith"
253a029335a2 split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents: 55315
diff changeset
    87
  | Presburger_Method => "presburger"
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    88
  | Algebra_Method => "algebra")
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    89
55452
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    90
(* Makes proof methods as silent as possible. The "set_visible" calls suppresses "Unification bound
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    91
   exceeded" warnings and the like. *)
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    92
fun silence_proof_methods debug =
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    93
  Try0.silence_methods debug
56081
72fad75baf7e integrate SMT2 with Sledgehammer
blanchet
parents: 55452
diff changeset
    94
  #> Config.put SMT2_Config.verbose debug
55452
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    95
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    96
fun tac_of_proof_method ctxt0 debug (local_facts, global_facts) meth =
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    97
  let val ctxt = silence_proof_methods debug ctxt0 in
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
    98
    Method.insert_tac local_facts THEN'
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
    99
    (case meth of
55452
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   100
      Metis_Method (type_enc_opt, lam_trans_opt) =>
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   101
      Metis_Tactic.metis_tac [type_enc_opt |> the_default (hd partial_type_encs)]
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   102
        (lam_trans_opt |> the_default default_metis_lam_trans) ctxt global_facts
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   103
    | Meson_Method => Meson.meson_tac ctxt global_facts
56081
72fad75baf7e integrate SMT2 with Sledgehammer
blanchet
parents: 55452
diff changeset
   104
    | SMT2_Method => SMT2_Solver.smt2_tac ctxt global_facts
55452
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   105
    | _ =>
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   106
      Method.insert_tac global_facts THEN'
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   107
      (case meth of
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   108
        Blast_Method => blast_tac ctxt
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   109
      | Simp_Method => Simplifier.asm_full_simp_tac ctxt
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   110
      | Simp_Size_Method =>
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   111
        Simplifier.asm_full_simp_tac (Simplifier.add_simp @{thm size_ne_size_imp_ne} ctxt)
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   112
      | Auto_Method => K (Clasimp.auto_tac ctxt)
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   113
      | Fastforce_Method => Clasimp.fast_force_tac ctxt
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   114
      | Force_Method => Clasimp.force_tac ctxt
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   115
      | Linarith_Method => Lin_Arith.tac ctxt
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   116
      | Presburger_Method => Cooper.tac true [] [] ctxt
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   117
      | Algebra_Method => Groebner.algebra_tac [] [] ctxt))
29ec8680e61f avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents: 55451
diff changeset
   118
  end
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   119
54828
b2271ad695db don't do 'isar_try0' if preplaying is off
blanchet
parents: 54824
diff changeset
   120
fun string_of_play_outcome (Played time) = string_of_ext_time (false, time)
56093
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   121
  | string_of_play_outcome (Play_Timed_Out time) =
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   122
    if time = Time.zeroTime then "" else string_of_ext_time (true, time) ^ ", timed out"
54828
b2271ad695db don't do 'isar_try0' if preplaying is off
blanchet
parents: 54824
diff changeset
   123
  | string_of_play_outcome Play_Failed = "failed"
b2271ad695db don't do 'isar_try0' if preplaying is off
blanchet
parents: 54824
diff changeset
   124
55269
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   125
fun play_outcome_ord (Played time1, Played time2) =
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   126
    int_ord (pairself Time.toMilliseconds (time1, time2))
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   127
  | play_outcome_ord (Played _, _) = LESS
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   128
  | play_outcome_ord (_, Played _) = GREATER
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   129
  | play_outcome_ord (Play_Timed_Out time1, Play_Timed_Out time2) =
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   130
    int_ord (pairself Time.toMilliseconds (time1, time2))
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   131
  | play_outcome_ord (Play_Timed_Out _, _) = LESS
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   132
  | play_outcome_ord (_, Play_Timed_Out _) = GREATER
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   133
  | play_outcome_ord (Play_Failed, Play_Failed) = EQUAL
aae87746f412 more thorough, hybrid compression
blanchet
parents: 55212
diff changeset
   134
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   135
(* FIXME: Various bugs, esp. with "unfolding"
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   136
fun unusing_chained_facts _ 0 = ""
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   137
  | unusing_chained_facts used_chaineds num_chained =
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   138
    if length used_chaineds = num_chained then ""
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   139
    else if null used_chaineds then "(* using no facts *) "
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   140
    else "(* using only " ^ space_implode " " used_chaineds ^ " *) "
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   141
*)
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   142
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   143
fun apply_on_subgoal _ 1 = "by "
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   144
  | apply_on_subgoal 1 _ = "apply "
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   145
  | apply_on_subgoal i n =
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   146
    "prefer " ^ string_of_int i ^ " " ^ apply_on_subgoal 1 n
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   147
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   148
fun command_call name [] =
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   149
    name |> not (Symbol_Pos.is_identifier name) ? enclose "(" ")"
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   150
  | command_call name args = "(" ^ name ^ " " ^ space_implode " " args ^ ")"
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   151
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
   152
(* FIXME *)
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
   153
fun proof_method_command meth i n used_chaineds num_chained ss =
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   154
  (* unusing_chained_facts used_chaineds num_chained ^ *)
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
   155
  apply_on_subgoal i n ^ command_call (string_of_proof_method meth) ss
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   156
56093
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   157
fun try_command_line banner play command =
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   158
  let val s = string_of_play_outcome play in
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   159
    banner ^ ": " ^ Active.sendback_markup [Markup.padding_command] command ^
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   160
    (s |> s <> "" ? enclose " (" ")") ^ "."
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   161
  end
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
   162
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   163
fun minimize_line _ [] = ""
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   164
  | minimize_line minimize_command ss =
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   165
    (case minimize_command ss of
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   166
      "" => ""
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   167
    | command => "\nTo minimize: " ^ Active.sendback_markup [Markup.padding_command] command ^ ".")
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   168
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   169
fun split_used_facts facts =
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   170
  facts
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   171
  |> List.partition (fn (_, (sc, _)) => sc = Chained)
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   172
  |> pairself (sort_distinct (string_ord o pairself fst))
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   173
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   174
fun one_line_proof_text num_chained
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
   175
    ((meth, play), banner, used_facts, minimize_command, subgoal, subgoal_count) =
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   176
  let
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   177
    val (chained, extra) = split_used_facts used_facts
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   178
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   179
    val try_line =
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   180
      map fst extra
55285
e88ad20035f4 merged 'reconstructors' and 'proof methods'
blanchet
parents: 55269
diff changeset
   181
      |> proof_method_command meth subgoal subgoal_count (map fst chained) num_chained
56093
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   182
      |> (if play = Play_Failed then enclose "One-line proof reconstruction failed: " "."
4eeb73a1feec simplified preplaying information
blanchet
parents: 56081
diff changeset
   183
          else try_command_line banner play)
55211
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   184
  in
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   185
    try_line ^ minimize_line minimize_command (map fst (extra @ chained))
5d027af93a08 moved ML code around
blanchet
parents: 55180
diff changeset
   186
  end
52555
6811291d1869 moved code -> easier debugging
smolkas
parents:
diff changeset
   187
54495
237d5be57277 refactored
blanchet
parents: 52590
diff changeset
   188
end;