src/HOL/Tools/Old_Datatype/old_datatype_aux.ML
changeset 59582 0fbed69ff081
parent 59498 50b60f501b05
child 59617 b60e65ad13df
equal deleted inserted replaced
59580:cbc38731d42f 59582:0fbed69ff081
   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 indrule indnames = CSUBGOAL (fn (cgoal, i) =>
   128   let
   128   let
   129     val cert = cterm_of (Thm.theory_of_cterm cgoal);
   129     val cert = Thm.cterm_of (Thm.theory_of_cterm cgoal);
   130     val goal = term_of cgoal;
   130     val goal = Thm.term_of cgoal;
   131     val ts = HOLogic.dest_conj (HOLogic.dest_Trueprop (concl_of indrule));
   131     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));
   132     val ts' = HOLogic.dest_conj (HOLogic.dest_Trueprop (Logic.strip_imp_concl goal));
   133     val getP =
   133     val getP =
   134       if can HOLogic.dest_imp (hd ts)
   134       if can HOLogic.dest_imp (hd ts)
   135       then apfst SOME o HOLogic.dest_imp
   135       then apfst SOME o HOLogic.dest_imp
   136       else pair NONE;
   136       else pair NONE;
   156 (* perform exhaustive case analysis on last parameter of subgoal i *)
   156 (* perform exhaustive case analysis on last parameter of subgoal i *)
   157 
   157 
   158 fun exh_tac ctxt exh_thm_of = CSUBGOAL (fn (cgoal, i) =>
   158 fun exh_tac ctxt exh_thm_of = CSUBGOAL (fn (cgoal, i) =>
   159   let
   159   let
   160     val thy = Thm.theory_of_cterm cgoal;
   160     val thy = Thm.theory_of_cterm cgoal;
   161     val goal = term_of cgoal;
   161     val goal = Thm.term_of cgoal;
   162     val params = Logic.strip_params goal;
   162     val params = Logic.strip_params goal;
   163     val (_, Type (tname, _)) = hd (rev params);
   163     val (_, Type (tname, _)) = hd (rev params);
   164     val exhaustion = Thm.lift_rule cgoal (exh_thm_of tname);
   164     val exhaustion = Thm.lift_rule cgoal (exh_thm_of tname);
   165     val prem' = hd (prems_of exhaustion);
   165     val prem' = hd (Thm.prems_of exhaustion);
   166     val _ $ (_ $ lhs $ _) = hd (rev (Logic.strip_assums_hyp prem'));
   166     val _ $ (_ $ lhs $ _) = hd (rev (Logic.strip_assums_hyp prem'));
   167     val exhaustion' =
   167     val exhaustion' =
   168       cterm_instantiate [(cterm_of thy (head_of lhs),
   168       cterm_instantiate
   169         cterm_of thy (fold_rev (fn (_, T) => fn t => Abs ("z", T, t)) params (Bound 0)))] exhaustion;
   169         [(Thm.cterm_of thy (head_of lhs),
   170   in compose_tac ctxt (false, exhaustion', nprems_of exhaustion) i end);
   170           Thm.cterm_of thy (fold_rev (fn (_, T) => fn t => Abs ("z", T, t)) params (Bound 0)))]
       
   171         exhaustion;
       
   172   in compose_tac ctxt (false, exhaustion', Thm.nprems_of exhaustion) i end);
   171 
   173 
   172 
   174 
   173 (********************** Internal description of datatypes *********************)
   175 (********************** Internal description of datatypes *********************)
   174 
   176 
   175 datatype dtyp =
   177 datatype dtyp =