src/Pure/Isar/proof.ML
changeset 54742 7a86358a3c0b
parent 54567 cfe53047dc16
child 54981 a128df2f670e
equal deleted inserted replaced
54741:010eefa0a4f3 54742:7a86358a3c0b
   441 
   441 
   442 (* refine via sub-proof *)
   442 (* refine via sub-proof *)
   443 
   443 
   444 local
   444 local
   445 
   445 
   446 fun finish_tac 0 = K all_tac
   446 fun finish_tac _ 0 = K all_tac
   447   | finish_tac n =
   447   | finish_tac ctxt n =
   448       Goal.norm_hhf_tac THEN'
   448       Goal.norm_hhf_tac ctxt THEN'
   449       SUBGOAL (fn (goal, i) =>
   449       SUBGOAL (fn (goal, i) =>
   450         if can Logic.unprotect (Logic.strip_assums_concl goal) then
   450         if can Logic.unprotect (Logic.strip_assums_concl goal) then
   451           etac Drule.protectI i THEN finish_tac (n - 1) i
   451           etac Drule.protectI i THEN finish_tac ctxt (n - 1) i
   452         else finish_tac (n - 1) (i + 1));
   452         else finish_tac ctxt (n - 1) (i + 1));
   453 
   453 
   454 fun goal_tac rule =
   454 fun goal_tac ctxt rule =
   455   Goal.norm_hhf_tac THEN'
   455   Goal.norm_hhf_tac ctxt THEN'
   456   rtac rule THEN'
   456   rtac rule THEN'
   457   finish_tac (Thm.nprems_of rule);
   457   finish_tac ctxt (Thm.nprems_of rule);
   458 
   458 
   459 fun FINDGOAL tac st =
   459 fun FINDGOAL tac st =
   460   let fun find i n = if i > n then Seq.fail else Seq.APPEND (tac i, find (i + 1) n)
   460   let fun find i n = if i > n then Seq.fail else Seq.APPEND (tac i, find (i + 1) n)
   461   in find 1 (Thm.nprems_of st) st end;
   461   in find 1 (Thm.nprems_of st) st end;
   462 
   462 
   463 in
   463 in
   464 
   464 
   465 fun refine_goals print_rule inner raw_rules state =
   465 fun refine_goals print_rule inner raw_rules state =
   466   let
   466   let
   467     val (outer, (_, goal)) = get_goal state;
   467     val (outer, (_, goal)) = get_goal state;
   468     fun refine rule st = (print_rule outer rule; FINDGOAL (goal_tac rule) st);
   468     fun refine rule st = (print_rule outer rule; FINDGOAL (goal_tac outer rule) st);
   469   in
   469   in
   470     raw_rules
   470     raw_rules
   471     |> Proof_Context.goal_export inner outer
   471     |> Proof_Context.goal_export inner outer
   472     |> (fn rules => Seq.lift provide_goal (EVERY (map refine rules) goal) state)
   472     |> (fn rules => Seq.lift provide_goal (EVERY (map refine rules) goal) state)
   473   end;
   473   end;