src/Tools/induct.ML
changeset 56245 84fc7dfa3cd4
parent 56231 b98813774a63
child 56334 6b3739fee456
equal deleted inserted replaced
56244:3298b7a2795a 56245:84fc7dfa3cd4
   160   (case find_eq ctxt (term_of ct) of
   160   (case find_eq ctxt (term_of ct) of
   161     NONE => NONE
   161     NONE => NONE
   162   | SOME (i, k, j) => SOME (swap_params_conv ctxt k j (K (swap_prems_conv i)) ct));
   162   | SOME (i, k, j) => SOME (swap_params_conv ctxt k j (K (swap_prems_conv i)) ct));
   163 
   163 
   164 val rearrange_eqs_simproc =
   164 val rearrange_eqs_simproc =
   165   Simplifier.simproc_global Pure.thy "rearrange_eqs" ["all t"]
   165   Simplifier.simproc_global Pure.thy "rearrange_eqs" ["Pure.all t"]
   166     (fn ctxt => fn t => mk_swap_rrule ctxt (cterm_of (Proof_Context.theory_of ctxt) t));
   166     (fn ctxt => fn t => mk_swap_rrule ctxt (cterm_of (Proof_Context.theory_of ctxt) t));
   167 
   167 
   168 
   168 
   169 (* rotate k premises to the left by j, skipping over first j premises *)
   169 (* rotate k premises to the left by j, skipping over first j premises *)
   170 
   170 
   642 
   642 
   643 (* arbitrary_tac *)
   643 (* arbitrary_tac *)
   644 
   644 
   645 local
   645 local
   646 
   646 
   647 fun goal_prefix k ((c as Const ("all", _)) $ Abs (a, T, B)) = c $ Abs (a, T, goal_prefix k B)
   647 fun goal_prefix k ((c as Const (@{const_name Pure.all}, _)) $ Abs (a, T, B)) =
       
   648       c $ Abs (a, T, goal_prefix k B)
   648   | goal_prefix 0 _ = Term.dummy_prop
   649   | goal_prefix 0 _ = Term.dummy_prop
   649   | goal_prefix k ((c as Const ("==>", _)) $ A $ B) = c $ A $ goal_prefix (k - 1) B
   650   | goal_prefix k ((c as Const (@{const_name Pure.imp}, _)) $ A $ B) =
       
   651       c $ A $ goal_prefix (k - 1) B
   650   | goal_prefix _ _ = Term.dummy_prop;
   652   | goal_prefix _ _ = Term.dummy_prop;
   651 
   653 
   652 fun goal_params k (Const ("all", _) $ Abs (_, _, B)) = goal_params k B + 1
   654 fun goal_params k (Const (@{const_name Pure.all}, _) $ Abs (_, _, B)) = goal_params k B + 1
   653   | goal_params 0 _ = 0
   655   | goal_params 0 _ = 0
   654   | goal_params k (Const ("==>", _) $ _ $ B) = goal_params (k - 1) B
   656   | goal_params k (Const (@{const_name Pure.imp}, _) $ _ $ B) = goal_params (k - 1) B
   655   | goal_params _ _ = 0;
   657   | goal_params _ _ = 0;
   656 
   658 
   657 fun meta_spec_tac ctxt n (x, T) = SUBGOAL (fn (goal, i) =>
   659 fun meta_spec_tac ctxt n (x, T) = SUBGOAL (fn (goal, i) =>
   658   let
   660   let
   659     val thy = Proof_Context.theory_of ctxt;
   661     val thy = Proof_Context.theory_of ctxt;
   668       |-> (fn pred $ arg =>
   670       |-> (fn pred $ arg =>
   669         Drule.cterm_instantiate
   671         Drule.cterm_instantiate
   670           [(cert (Term.head_of pred), cert (Logic.rlist_abs (xs, body))),
   672           [(cert (Term.head_of pred), cert (Logic.rlist_abs (xs, body))),
   671            (cert (Term.head_of arg), cert (Logic.rlist_abs (xs, v)))]);
   673            (cert (Term.head_of arg), cert (Logic.rlist_abs (xs, v)))]);
   672 
   674 
   673     fun goal_concl k xs (Const ("all", _) $ Abs (a, T, B)) = goal_concl k ((a, T) :: xs) B
   675     fun goal_concl k xs (Const (@{const_name Pure.all}, _) $ Abs (a, T, B)) =
       
   676           goal_concl k ((a, T) :: xs) B
   674       | goal_concl 0 xs B =
   677       | goal_concl 0 xs B =
   675           if not (Term.exists_subterm (fn t => t aconv v) B) then NONE
   678           if not (Term.exists_subterm (fn t => t aconv v) B) then NONE
   676           else SOME (xs, absfree (x, T) (Term.incr_boundvars 1 B))
   679           else SOME (xs, absfree (x, T) (Term.incr_boundvars 1 B))
   677       | goal_concl k xs (Const ("==>", _) $ _ $ B) = goal_concl (k - 1) xs B
   680       | goal_concl k xs (Const (@{const_name Pure.imp}, _) $ _ $ B) =
       
   681           goal_concl (k - 1) xs B
   678       | goal_concl _ _ _ = NONE;
   682       | goal_concl _ _ _ = NONE;
   679   in
   683   in
   680     (case goal_concl n [] goal of
   684     (case goal_concl n [] goal of
   681       SOME concl =>
   685       SOME concl =>
   682         (compose_tac (false, spec_rule (goal_prefix n goal) concl, 1) THEN' rtac asm_rl) i
   686         (compose_tac (false, spec_rule (goal_prefix n goal) concl, 1) THEN' rtac asm_rl) i