src/Pure/goal.ML
author wenzelm
Thu Aug 30 15:26:37 2012 +0200 (2012-08-30)
changeset 49009 15381ea111ec
parent 48992 0518bf89c777
child 49012 8686c36fa27d
permissions -rw-r--r--
refined status of forked goals;
wenzelm@17980
     1
(*  Title:      Pure/goal.ML
wenzelm@29345
     2
    Author:     Makarius
wenzelm@17980
     3
wenzelm@18139
     4
Goals in tactical theorem proving.
wenzelm@17980
     5
*)
wenzelm@17980
     6
wenzelm@17980
     7
signature BASIC_GOAL =
wenzelm@17980
     8
sig
wenzelm@32738
     9
  val parallel_proofs: int Unsynchronized.ref
wenzelm@41703
    10
  val parallel_proofs_threshold: int Unsynchronized.ref
wenzelm@17980
    11
  val SELECT_GOAL: tactic -> int -> tactic
wenzelm@23418
    12
  val CONJUNCTS: tactic -> int -> tactic
wenzelm@23414
    13
  val PRECISE_CONJUNCTS: int -> tactic -> int -> tactic
wenzelm@32365
    14
  val PARALLEL_CHOICE: tactic list -> tactic
wenzelm@32365
    15
  val PARALLEL_GOALS: tactic -> tactic
wenzelm@17980
    16
end;
wenzelm@17980
    17
wenzelm@17980
    18
signature GOAL =
wenzelm@17980
    19
sig
wenzelm@17980
    20
  include BASIC_GOAL
wenzelm@17980
    21
  val init: cterm -> thm
wenzelm@18027
    22
  val protect: thm -> thm
wenzelm@17980
    23
  val conclude: thm -> thm
wenzelm@32197
    24
  val check_finished: Proof.context -> thm -> unit
wenzelm@32197
    25
  val finish: Proof.context -> thm -> thm
wenzelm@21604
    26
  val norm_result: thm -> thm
wenzelm@41677
    27
  val fork_name: string -> (unit -> 'a) -> 'a future
wenzelm@37186
    28
  val fork: (unit -> 'a) -> 'a future
wenzelm@29448
    29
  val future_enabled: unit -> bool
wenzelm@32061
    30
  val local_future_enabled: unit -> bool
wenzelm@28973
    31
  val future_result: Proof.context -> thm future -> term -> thm
wenzelm@23356
    32
  val prove_internal: cterm list -> cterm -> (thm list -> tactic) -> thm
wenzelm@20290
    33
  val prove_multi: Proof.context -> string list -> term list -> term list ->
wenzelm@20290
    34
    ({prems: thm list, context: Proof.context} -> tactic) -> thm list
wenzelm@28446
    35
  val prove_future: Proof.context -> string list -> term list -> term ->
wenzelm@28340
    36
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
wenzelm@20290
    37
  val prove: Proof.context -> string list -> term list -> term ->
wenzelm@20290
    38
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
wenzelm@26713
    39
  val prove_global: theory -> string list -> term list -> term ->
wenzelm@26713
    40
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
wenzelm@19184
    41
  val extract: int -> int -> thm -> thm Seq.seq
wenzelm@19184
    42
  val retrofit: int -> int -> thm -> thm -> thm Seq.seq
wenzelm@23418
    43
  val conjunction_tac: int -> tactic
wenzelm@23414
    44
  val precise_conjunction_tac: int -> int -> tactic
wenzelm@23418
    45
  val recover_conjunction_tac: tactic
wenzelm@21687
    46
  val norm_hhf_tac: int -> tactic
wenzelm@21687
    47
  val compose_hhf_tac: thm -> int -> tactic
wenzelm@23237
    48
  val assume_rule_tac: Proof.context -> int -> tactic
wenzelm@17980
    49
end;
wenzelm@17980
    50
wenzelm@17980
    51
structure Goal: GOAL =
wenzelm@17980
    52
struct
wenzelm@17980
    53
wenzelm@18027
    54
(** goals **)
wenzelm@18027
    55
wenzelm@18027
    56
(*
wenzelm@18027
    57
  -------- (init)
wenzelm@18027
    58
  C ==> #C
wenzelm@18027
    59
*)
wenzelm@20290
    60
val init =
wenzelm@22902
    61
  let val A = #1 (Thm.dest_implies (Thm.cprop_of Drule.protectI))
wenzelm@20290
    62
  in fn C => Thm.instantiate ([], [(A, C)]) Drule.protectI end;
wenzelm@17980
    63
wenzelm@17980
    64
(*
wenzelm@18119
    65
   C
wenzelm@18119
    66
  --- (protect)
wenzelm@18119
    67
  #C
wenzelm@17980
    68
*)
wenzelm@29345
    69
fun protect th = Drule.comp_no_flatten (th, 0) 1 Drule.protectI;
wenzelm@17980
    70
wenzelm@17980
    71
(*
wenzelm@18027
    72
  A ==> ... ==> #C
wenzelm@18027
    73
  ---------------- (conclude)
wenzelm@17980
    74
  A ==> ... ==> C
wenzelm@17980
    75
*)
wenzelm@29345
    76
fun conclude th = Drule.comp_no_flatten (th, Thm.nprems_of th) 1 Drule.protectD;
wenzelm@17980
    77
wenzelm@17980
    78
(*
wenzelm@18027
    79
  #C
wenzelm@18027
    80
  --- (finish)
wenzelm@18027
    81
   C
wenzelm@17983
    82
*)
wenzelm@32197
    83
fun check_finished ctxt th =
wenzelm@17980
    84
  (case Thm.nprems_of th of
wenzelm@32197
    85
    0 => ()
wenzelm@17980
    86
  | n => raise THM ("Proof failed.\n" ^
wenzelm@32197
    87
      Pretty.string_of (Pretty.chunks
wenzelm@39125
    88
        (Goal_Display.pretty_goals
wenzelm@39125
    89
          (ctxt
wenzelm@39125
    90
            |> Config.put Goal_Display.goals_limit n
wenzelm@39125
    91
            |> Config.put Goal_Display.show_main_goal true) th)) ^
wenzelm@32197
    92
      "\n" ^ string_of_int n ^ " unsolved goal(s)!", 0, [th]));
wenzelm@32197
    93
wenzelm@32197
    94
fun finish ctxt th = (check_finished ctxt th; conclude th);
wenzelm@17980
    95
wenzelm@17980
    96
wenzelm@18027
    97
wenzelm@18027
    98
(** results **)
wenzelm@18027
    99
wenzelm@28340
   100
(* normal form *)
wenzelm@28340
   101
wenzelm@21604
   102
val norm_result =
wenzelm@21604
   103
  Drule.flexflex_unique
wenzelm@41228
   104
  #> Raw_Simplifier.norm_hhf_protect
wenzelm@21604
   105
  #> Thm.strip_shyps
wenzelm@21604
   106
  #> Drule.zero_var_indexes;
wenzelm@21604
   107
wenzelm@21604
   108
wenzelm@41703
   109
(* forked proofs *)
wenzelm@41703
   110
wenzelm@41703
   111
val forked_proofs = Synchronized.var "forked_proofs" 0;
wenzelm@41703
   112
wenzelm@41703
   113
fun forked i =
wenzelm@41703
   114
  Synchronized.change forked_proofs (fn m =>
wenzelm@41703
   115
    let
wenzelm@41703
   116
      val n = m + i;
wenzelm@41703
   117
      val _ =
wenzelm@41776
   118
        Multithreading.tracing 2 (fn () =>
wenzelm@41703
   119
          ("PROOFS " ^ Time.toString (Time.now ()) ^ ": " ^ string_of_int n));
wenzelm@41703
   120
    in n end);
wenzelm@37186
   121
wenzelm@49009
   122
fun capture_status e =
wenzelm@49009
   123
  let
wenzelm@49009
   124
    val task_props =
wenzelm@49009
   125
      (case Future.worker_task () of
wenzelm@49009
   126
        NONE => I
wenzelm@49009
   127
      | SOME task => Markup.properties [(Isabelle_Markup.taskN, Task_Queue.str_of_task task)]);
wenzelm@49009
   128
    fun status m = Output.status (Markup.markup_only (task_props m));
wenzelm@49009
   129
wenzelm@49009
   130
    val _ = status Isabelle_Markup.forked;
wenzelm@49009
   131
    val result = Exn.capture (Future.interruptible_task e) ();
wenzelm@49009
   132
    val _ =
wenzelm@49009
   133
      (case result of
wenzelm@49009
   134
        Exn.Res _ => status Isabelle_Markup.joined
wenzelm@49009
   135
      | Exn.Exn exn =>
wenzelm@49009
   136
          if Exn.is_interrupt exn then status Isabelle_Markup.cancelled
wenzelm@49009
   137
          else status Isabelle_Markup.failed);
wenzelm@49009
   138
  in result end;
wenzelm@49009
   139
wenzelm@41677
   140
fun fork_name name e =
wenzelm@41703
   141
  uninterruptible (fn _ => fn () =>
wenzelm@41703
   142
    let
wenzelm@41703
   143
      val _ = forked 1;
wenzelm@41703
   144
      val future =
wenzelm@44302
   145
        (singleton o Future.forks)
wenzelm@47415
   146
          {name = name, group = NONE, deps = [], pri = ~1, interrupts = false}
wenzelm@49009
   147
          (fn () => Exn.release (capture_status e before forked ~1));
wenzelm@41703
   148
    in future end) ();
wenzelm@29448
   149
wenzelm@41677
   150
fun fork e = fork_name "Goal.fork" e;
wenzelm@41677
   151
wenzelm@41677
   152
wenzelm@41703
   153
(* scheduling parameters *)
wenzelm@41703
   154
wenzelm@32738
   155
val parallel_proofs = Unsynchronized.ref 1;
wenzelm@41819
   156
val parallel_proofs_threshold = Unsynchronized.ref 50;
wenzelm@29448
   157
wenzelm@29448
   158
fun future_enabled () =
wenzelm@41703
   159
  Multithreading.enabled () andalso ! parallel_proofs >= 1 andalso
wenzelm@41703
   160
  is_some (Future.worker_task ());
wenzelm@32061
   161
wenzelm@41703
   162
fun local_future_enabled () =
wenzelm@41703
   163
  future_enabled () andalso ! parallel_proofs >= 2 andalso
wenzelm@41819
   164
  Synchronized.value forked_proofs <
wenzelm@41819
   165
    ! parallel_proofs_threshold * Multithreading.max_threads_value ();
wenzelm@29448
   166
wenzelm@29448
   167
wenzelm@28446
   168
(* future_result *)
wenzelm@28340
   169
wenzelm@28446
   170
fun future_result ctxt result prop =
wenzelm@28340
   171
  let
wenzelm@42360
   172
    val thy = Proof_Context.theory_of ctxt;
wenzelm@28340
   173
    val _ = Context.reject_draft thy;
wenzelm@28340
   174
    val cert = Thm.cterm_of thy;
wenzelm@28340
   175
    val certT = Thm.ctyp_of thy;
wenzelm@28340
   176
wenzelm@30473
   177
    val assms = Assumption.all_assms_of ctxt;
wenzelm@28340
   178
    val As = map Thm.term_of assms;
wenzelm@28340
   179
wenzelm@28340
   180
    val xs = map Free (fold Term.add_frees (prop :: As) []);
wenzelm@28340
   181
    val fixes = map cert xs;
wenzelm@28340
   182
wenzelm@28340
   183
    val tfrees = fold Term.add_tfrees (prop :: As) [];
wenzelm@28340
   184
    val instT = map (fn (a, S) => (certT (TVar ((a, 0), S)), certT (TFree (a, S)))) tfrees;
wenzelm@28340
   185
wenzelm@28340
   186
    val global_prop =
wenzelm@45344
   187
      cert (Logic.varify_types_global (fold_rev Logic.all xs (Logic.list_implies (As, prop))))
wenzelm@32056
   188
      |> Thm.weaken_sorts (Variable.sorts_of ctxt);
wenzelm@28973
   189
    val global_result = result |> Future.map
wenzelm@33768
   190
      (Drule.flexflex_unique #>
wenzelm@33768
   191
        Thm.adjust_maxidx_thm ~1 #>
wenzelm@28973
   192
        Drule.implies_intr_list assms #>
wenzelm@28973
   193
        Drule.forall_intr_list fixes #>
wenzelm@36613
   194
        Thm.generalize (map #1 tfrees, []) 0 #>
wenzelm@36613
   195
        Thm.strip_shyps);
wenzelm@28340
   196
    val local_result =
wenzelm@32056
   197
      Thm.future global_result global_prop
wenzelm@28340
   198
      |> Thm.instantiate (instT, [])
wenzelm@28340
   199
      |> Drule.forall_elim_list fixes
wenzelm@28340
   200
      |> fold (Thm.elim_implies o Thm.assume) assms;
wenzelm@28340
   201
  in local_result end;
wenzelm@28340
   202
wenzelm@28340
   203
wenzelm@18027
   204
wenzelm@18027
   205
(** tactical theorem proving **)
wenzelm@18027
   206
wenzelm@23356
   207
(* prove_internal -- minimal checks, no normalization of result! *)
wenzelm@20250
   208
wenzelm@23356
   209
fun prove_internal casms cprop tac =
wenzelm@20250
   210
  (case SINGLE (tac (map Assumption.assume casms)) (init cprop) of
wenzelm@32197
   211
    SOME th => Drule.implies_intr_list casms
wenzelm@32197
   212
      (finish (Syntax.init_pretty_global (Thm.theory_of_thm th)) th)
wenzelm@38875
   213
  | NONE => error "Tactic failed");
wenzelm@20250
   214
wenzelm@20250
   215
wenzelm@28340
   216
(* prove_common etc. *)
wenzelm@17986
   217
wenzelm@28340
   218
fun prove_common immediate ctxt xs asms props tac =
wenzelm@17980
   219
  let
wenzelm@42360
   220
    val thy = Proof_Context.theory_of ctxt;
wenzelm@26939
   221
    val string_of_term = Syntax.string_of_term ctxt;
wenzelm@20056
   222
wenzelm@28355
   223
    val pos = Position.thread_data ();
wenzelm@20250
   224
    fun err msg = cat_error msg
wenzelm@20250
   225
      ("The error(s) above occurred for the goal statement:\n" ^
wenzelm@28355
   226
        string_of_term (Logic.list_implies (asms, Logic.mk_conjunction_list props)) ^
wenzelm@48992
   227
        (case Position.here pos of "" => "" | s => "\n" ^ s));
wenzelm@17980
   228
wenzelm@20250
   229
    fun cert_safe t = Thm.cterm_of thy (Envir.beta_norm (Term.no_dummy_patterns t))
wenzelm@17980
   230
      handle TERM (msg, _) => err msg | TYPE (msg, _, _) => err msg;
wenzelm@20250
   231
    val casms = map cert_safe asms;
wenzelm@20250
   232
    val cprops = map cert_safe props;
wenzelm@17980
   233
wenzelm@20250
   234
    val (prems, ctxt') = ctxt
wenzelm@20250
   235
      |> Variable.add_fixes_direct xs
wenzelm@27218
   236
      |> fold Variable.declare_term (asms @ props)
wenzelm@26713
   237
      |> Assumption.add_assumes casms
wenzelm@26713
   238
      ||> Variable.set_body true;
wenzelm@28619
   239
    val sorts = Variable.sorts_of ctxt';
wenzelm@17980
   240
wenzelm@28619
   241
    val stmt = Thm.weaken_sorts sorts (Conjunction.mk_conjunction_balanced cprops);
wenzelm@28340
   242
wenzelm@28340
   243
    fun result () =
wenzelm@28340
   244
      (case SINGLE (tac {prems = prems, context = ctxt'}) (init stmt) of
wenzelm@38875
   245
        NONE => err "Tactic failed"
wenzelm@28340
   246
      | SOME st =>
wenzelm@32197
   247
          let val res = finish ctxt' st handle THM (msg, _, _) => err msg in
wenzelm@28619
   248
            if Unify.matches_list thy [Thm.term_of stmt] [Thm.prop_of res]
wenzelm@28619
   249
            then Thm.check_shyps sorts res
wenzelm@28340
   250
            else err ("Proved a different theorem: " ^ string_of_term (Thm.prop_of res))
wenzelm@28340
   251
          end);
wenzelm@28340
   252
    val res =
wenzelm@29448
   253
      if immediate orelse #maxidx (Thm.rep_cterm stmt) >= 0 orelse not (future_enabled ())
wenzelm@29088
   254
      then result ()
wenzelm@37186
   255
      else future_result ctxt' (fork result) (Thm.term_of stmt);
wenzelm@17980
   256
  in
wenzelm@28340
   257
    Conjunction.elim_balanced (length props) res
wenzelm@20290
   258
    |> map (Assumption.export false ctxt' ctxt)
wenzelm@20056
   259
    |> Variable.export ctxt' ctxt
wenzelm@20250
   260
    |> map Drule.zero_var_indexes
wenzelm@17980
   261
  end;
wenzelm@17980
   262
wenzelm@28341
   263
val prove_multi = prove_common true;
wenzelm@17980
   264
wenzelm@28446
   265
fun prove_future ctxt xs asms prop tac = hd (prove_common false ctxt xs asms [prop] tac);
wenzelm@28340
   266
fun prove ctxt xs asms prop tac = hd (prove_common true ctxt xs asms [prop] tac);
wenzelm@20056
   267
wenzelm@20056
   268
fun prove_global thy xs asms prop tac =
wenzelm@42360
   269
  Drule.export_without_context (prove (Proof_Context.init_global thy) xs asms prop tac);
wenzelm@18027
   270
wenzelm@18027
   271
wenzelm@17980
   272
wenzelm@21687
   273
(** goal structure **)
wenzelm@21687
   274
wenzelm@21687
   275
(* nested goals *)
wenzelm@18207
   276
wenzelm@19184
   277
fun extract i n st =
wenzelm@19184
   278
  (if i < 1 orelse n < 1 orelse i + n - 1 > Thm.nprems_of st then Seq.empty
wenzelm@19184
   279
   else if n = 1 then Seq.single (Thm.cprem_of st i)
wenzelm@23418
   280
   else
wenzelm@23418
   281
     Seq.single (Conjunction.mk_conjunction_balanced (map (Thm.cprem_of st) (i upto i + n - 1))))
wenzelm@20260
   282
  |> Seq.map (Thm.adjust_maxidx_cterm ~1 #> init);
wenzelm@17980
   283
wenzelm@19221
   284
fun retrofit i n st' st =
wenzelm@19221
   285
  (if n = 1 then st
wenzelm@23418
   286
   else st |> Drule.with_subgoal i (Conjunction.uncurry_balanced n))
wenzelm@19221
   287
  |> Thm.compose_no_flatten false (conclude st', Thm.nprems_of st') i;
wenzelm@18207
   288
wenzelm@17980
   289
fun SELECT_GOAL tac i st =
wenzelm@19191
   290
  if Thm.nprems_of st = 1 andalso i = 1 then tac st
wenzelm@19184
   291
  else Seq.lifts (retrofit i 1) (Seq.maps tac (extract i 1 st)) st;
wenzelm@17980
   292
wenzelm@21687
   293
wenzelm@21687
   294
(* multiple goals *)
wenzelm@21687
   295
wenzelm@23418
   296
fun precise_conjunction_tac 0 i = eq_assume_tac i
wenzelm@23418
   297
  | precise_conjunction_tac 1 i = SUBGOAL (K all_tac) i
wenzelm@23418
   298
  | precise_conjunction_tac n i = PRIMITIVE (Drule.with_subgoal i (Conjunction.curry_balanced n));
wenzelm@23414
   299
wenzelm@23418
   300
val adhoc_conjunction_tac = REPEAT_ALL_NEW
wenzelm@23418
   301
  (SUBGOAL (fn (goal, i) =>
wenzelm@23418
   302
    if can Logic.dest_conjunction goal then rtac Conjunction.conjunctionI i
wenzelm@23418
   303
    else no_tac));
wenzelm@21687
   304
wenzelm@23418
   305
val conjunction_tac = SUBGOAL (fn (goal, i) =>
wenzelm@23418
   306
  precise_conjunction_tac (length (Logic.dest_conjunctions goal)) i ORELSE
wenzelm@23418
   307
  TRY (adhoc_conjunction_tac i));
wenzelm@21687
   308
wenzelm@23418
   309
val recover_conjunction_tac = PRIMITIVE (fn th =>
wenzelm@23418
   310
  Conjunction.uncurry_balanced (Thm.nprems_of th) th);
wenzelm@23414
   311
wenzelm@23414
   312
fun PRECISE_CONJUNCTS n tac =
wenzelm@23414
   313
  SELECT_GOAL (precise_conjunction_tac n 1
wenzelm@23414
   314
    THEN tac
wenzelm@23418
   315
    THEN recover_conjunction_tac);
wenzelm@23414
   316
wenzelm@21687
   317
fun CONJUNCTS tac =
wenzelm@21687
   318
  SELECT_GOAL (conjunction_tac 1
wenzelm@21687
   319
    THEN tac
wenzelm@23418
   320
    THEN recover_conjunction_tac);
wenzelm@21687
   321
wenzelm@21687
   322
wenzelm@21687
   323
(* hhf normal form *)
wenzelm@21687
   324
wenzelm@21687
   325
val norm_hhf_tac =
wenzelm@21687
   326
  rtac Drule.asm_rl  (*cheap approximation -- thanks to builtin Logic.flatten_params*)
wenzelm@21687
   327
  THEN' SUBGOAL (fn (t, i) =>
wenzelm@21687
   328
    if Drule.is_norm_hhf t then all_tac
wenzelm@41228
   329
    else rewrite_goal_tac Drule.norm_hhf_eqs i);
wenzelm@21687
   330
wenzelm@25301
   331
fun compose_hhf_tac th i st =
wenzelm@25301
   332
  PRIMSEQ (Thm.bicompose false (false, Drule.lift_all (Thm.cprem_of st i) th, 0) i) st;
wenzelm@21687
   333
wenzelm@23237
   334
wenzelm@23237
   335
(* non-atomic goal assumptions *)
wenzelm@23237
   336
wenzelm@23356
   337
fun non_atomic (Const ("==>", _) $ _ $ _) = true
wenzelm@23356
   338
  | non_atomic (Const ("all", _) $ _) = true
wenzelm@23356
   339
  | non_atomic _ = false;
wenzelm@23356
   340
wenzelm@23237
   341
fun assume_rule_tac ctxt = norm_hhf_tac THEN' CSUBGOAL (fn (goal, i) =>
wenzelm@23237
   342
  let
wenzelm@42495
   343
    val ((_, goal'), ctxt') = Variable.focus_cterm goal ctxt;
wenzelm@23237
   344
    val goal'' = Drule.cterm_rule (singleton (Variable.export ctxt' ctxt)) goal';
wenzelm@23356
   345
    val Rs = filter (non_atomic o Thm.term_of) (Drule.strip_imp_prems goal'');
wenzelm@23237
   346
    val tacs = Rs |> map (fn R =>
wenzelm@41228
   347
      Tactic.etac (Raw_Simplifier.norm_hhf (Thm.trivial R)) THEN_ALL_NEW assume_tac);
wenzelm@23237
   348
  in fold_rev (curry op APPEND') tacs (K no_tac) i end);
wenzelm@23237
   349
wenzelm@32365
   350
wenzelm@32365
   351
(* parallel tacticals *)
wenzelm@32365
   352
wenzelm@32365
   353
(*parallel choice of single results*)
wenzelm@32365
   354
fun PARALLEL_CHOICE tacs st =
wenzelm@32365
   355
  (case Par_List.get_some (fn tac => SINGLE tac st) tacs of
wenzelm@32365
   356
    NONE => Seq.empty
wenzelm@32365
   357
  | SOME st' => Seq.single st');
wenzelm@32365
   358
wenzelm@32365
   359
(*parallel refinement of non-schematic goal by single results*)
wenzelm@32788
   360
exception FAILED of unit;
wenzelm@42370
   361
fun PARALLEL_GOALS tac =
wenzelm@42370
   362
  Thm.adjust_maxidx_thm ~1 #>
wenzelm@42370
   363
  (fn st =>
wenzelm@42371
   364
    if not (Multithreading.enabled ()) orelse Thm.maxidx_of st >= 0 orelse Thm.nprems_of st <= 1
wenzelm@42370
   365
    then DETERM tac st
wenzelm@42370
   366
    else
wenzelm@42370
   367
      let
wenzelm@42370
   368
        fun try_tac g =
wenzelm@42370
   369
          (case SINGLE tac g of
wenzelm@42370
   370
            NONE => raise FAILED ()
wenzelm@42370
   371
          | SOME g' => g');
wenzelm@32365
   372
wenzelm@42370
   373
        val goals = Drule.strip_imp_prems (Thm.cprop_of st);
wenzelm@42370
   374
        val results = Par_List.map (try_tac o init) goals;
wenzelm@42370
   375
      in ALLGOALS (fn i => retrofit i 1 (nth results (i - 1))) st end
wenzelm@42370
   376
      handle FAILED () => Seq.empty);
wenzelm@32365
   377
wenzelm@18207
   378
end;
wenzelm@18207
   379
wenzelm@32365
   380
structure Basic_Goal: BASIC_GOAL = Goal;
wenzelm@32365
   381
open Basic_Goal;