src/HOL/Tools/Old_Datatype/old_datatype_aux.ML
changeset 60328 9c94e6a30d29
parent 59621 291934bac95e
child 60757 c09598a97436
equal deleted inserted replaced
60327:a3f565b8ba76 60328:9c94e6a30d29
    50   val mk_conj : term list -> term
    50   val mk_conj : term list -> term
    51   val mk_disj : term list -> term
    51   val mk_disj : term list -> term
    52 
    52 
    53   val app_bnds : term -> int -> term
    53   val app_bnds : term -> int -> term
    54 
    54 
    55   val ind_tac : thm -> string list -> int -> tactic
    55   val ind_tac : Proof.context -> thm -> string list -> int -> tactic
    56   val exh_tac : Proof.context -> (string -> thm) -> int -> tactic
    56   val exh_tac : Proof.context -> (string -> thm) -> int -> tactic
    57 
    57 
    58   exception Datatype
    58   exception Datatype
    59   exception Datatype_Empty of string
    59   exception Datatype_Empty of string
    60   val name_of_typ : typ -> string
    60   val name_of_typ : typ -> string
   122 fun app_bnds t i = list_comb (t, map Bound (i - 1 downto 0));
   122 fun app_bnds t i = list_comb (t, map Bound (i - 1 downto 0));
   123 
   123 
   124 
   124 
   125 (* instantiate induction rule *)
   125 (* instantiate induction rule *)
   126 
   126 
   127 fun ind_tac indrule indnames = CSUBGOAL (fn (cgoal, i) =>
   127 fun ind_tac ctxt indrule indnames = CSUBGOAL (fn (cgoal, i) =>
   128   let
   128   let
   129     val thy = Thm.theory_of_cterm cgoal;
       
   130     val goal = Thm.term_of cgoal;
   129     val goal = Thm.term_of cgoal;
   131     val ts = HOLogic.dest_conj (HOLogic.dest_Trueprop (Thm.concl_of indrule));
   130     val ts = HOLogic.dest_conj (HOLogic.dest_Trueprop (Thm.concl_of indrule));
   132     val ts' = HOLogic.dest_conj (HOLogic.dest_Trueprop (Logic.strip_imp_concl goal));
   131     val ts' = HOLogic.dest_conj (HOLogic.dest_Trueprop (Logic.strip_imp_concl goal));
   133     val getP =
   132     val getP =
   134       if can HOLogic.dest_imp (hd ts)
   133       if can HOLogic.dest_imp (hd ts)
   143           (case flt (Term.add_frees t2 []) of
   142           (case flt (Term.add_frees t2 []) of
   144             [(s, T)] => SOME (absfree (s, T) t2)
   143             [(s, T)] => SOME (absfree (s, T) t2)
   145           | _ => NONE)
   144           | _ => NONE)
   146       | SOME (_ $ t') => SOME (Abs ("x", fastype_of t', abstract_over (t', t2))));
   145       | SOME (_ $ t') => SOME (Abs ("x", fastype_of t', abstract_over (t', t2))));
   147     val insts =
   146     val insts =
   148       map_filter (fn (t, u) =>
   147       (ts ~~ ts') |> map_filter (fn (t, u) =>
   149         (case abstr (getP u) of
   148         (case abstr (getP u) of
   150           NONE => NONE
   149           NONE => NONE
   151         | SOME u' =>
   150         | SOME u' => SOME (apply2 (Thm.cterm_of ctxt) (t |> getP |> snd |> head_of, u'))));
   152             SOME (apply2 (Thm.global_cterm_of thy) (t |> getP |> snd |> head_of, u')))) (ts ~~ ts');
       
   153     val indrule' = cterm_instantiate insts indrule;
   151     val indrule' = cterm_instantiate insts indrule;
   154   in resolve0_tac [indrule'] i end);
   152   in resolve0_tac [indrule'] i end);
   155 
   153 
   156 
   154 
   157 (* perform exhaustive case analysis on last parameter of subgoal i *)
   155 (* perform exhaustive case analysis on last parameter of subgoal i *)