src/Pure/Isar/obtain.ML
changeset 54883 dd04a8b654fc
parent 52456 960202346d0c
child 56897 c668735fb8b5
equal deleted inserted replaced
54882:61276a7fc369 54883:dd04a8b654fc
   192 
   192 
   193     val ((thesis_var, thesis), thesis_ctxt) = bind_judgment ctxt Auto_Bind.thesisN;
   193     val ((thesis_var, thesis), thesis_ctxt) = bind_judgment ctxt Auto_Bind.thesisN;
   194     val rule =
   194     val rule =
   195       (case SINGLE (Method.insert_tac facts 1 THEN tac thesis_ctxt) (Goal.init (cert thesis)) of
   195       (case SINGLE (Method.insert_tac facts 1 THEN tac thesis_ctxt) (Goal.init (cert thesis)) of
   196         NONE => raise THM ("Obtain.result: tactic failed", 0, facts)
   196         NONE => raise THM ("Obtain.result: tactic failed", 0, facts)
   197       | SOME th => check_result ctxt thesis (Raw_Simplifier.norm_hhf (Goal.conclude th)));
   197       | SOME th =>
       
   198           check_result thesis_ctxt thesis (Raw_Simplifier.norm_hhf thesis_ctxt (Goal.conclude th)));
   198 
   199 
   199     val closed_rule = Thm.forall_intr (cert (Free thesis_var)) rule;
   200     val closed_rule = Thm.forall_intr (cert (Free thesis_var)) rule;
   200     val ((_, [rule']), ctxt') = Variable.import false [closed_rule] ctxt;
   201     val ((_, [rule']), ctxt') = Variable.import false [closed_rule] ctxt;
   201     val obtain_rule = Thm.forall_elim (cert (Logic.varify_global (Free thesis_var))) rule';
   202     val obtain_rule = Thm.forall_elim (cert (Logic.varify_global (Free thesis_var))) rule';
   202     val ((params, stmt), fix_ctxt) = Variable.focus_cterm (Thm.cprem_of obtain_rule 1) ctxt';
   203     val ((params, stmt), fix_ctxt) = Variable.focus_cterm (Thm.cprem_of obtain_rule 1) ctxt';
   298       end;
   299       end;
   299 
   300 
   300     val goal = Var (("guess", 0), propT);
   301     val goal = Var (("guess", 0), propT);
   301     fun print_result ctxt' (k, [(s, [_, th])]) =
   302     fun print_result ctxt' (k, [(s, [_, th])]) =
   302       Proof_Display.print_results Markup.state int ctxt' (k, [(s, [th])]);
   303       Proof_Display.print_results Markup.state int ctxt' (k, [(s, [th])]);
   303     val before_qed = SOME (Method.primitive_text (Goal.conclude #> Raw_Simplifier.norm_hhf #>
   304     val before_qed =
   304         (fn th => Goal.protect 0 (Conjunction.intr (Drule.mk_term (Thm.cprop_of th)) th))));
   305       Method.primitive_text (fn ctxt =>
       
   306         Goal.conclude #> Raw_Simplifier.norm_hhf ctxt #>
       
   307           (fn th => Goal.protect 0 (Conjunction.intr (Drule.mk_term (Thm.cprop_of th)) th)));
   305     fun after_qed [[_, res]] =
   308     fun after_qed [[_, res]] =
   306       Proof.end_block #> guess_context (check_result ctxt thesis res);
   309       Proof.end_block #> guess_context (check_result ctxt thesis res);
   307   in
   310   in
   308     state
   311     state
   309     |> Proof.enter_forward
   312     |> Proof.enter_forward
   310     |> Proof.begin_block
   313     |> Proof.begin_block
   311     |> Proof.fix [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)]
   314     |> Proof.fix [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)]
   312     |> Proof.chain_facts chain_facts
   315     |> Proof.chain_facts chain_facts
   313     |> Proof.local_goal print_result (K I) (pair o rpair I)
   316     |> Proof.local_goal print_result (K I) (pair o rpair I)
   314       "guess" before_qed after_qed [(Thm.empty_binding, [Logic.mk_term goal, goal])]
   317       "guess" (SOME before_qed) after_qed [(Thm.empty_binding, [Logic.mk_term goal, goal])]
   315     |> Proof.refine (Method.primitive_text (K (Goal.init (cert thesis)))) |> Seq.hd
   318     |> Proof.refine (Method.primitive_text (fn _ => fn _ => Goal.init (cert thesis))) |> Seq.hd
   316   end;
   319   end;
   317 
   320 
   318 in
   321 in
   319 
   322 
   320 val guess = gen_guess Proof_Context.cert_vars;
   323 val guess = gen_guess Proof_Context.cert_vars;