src/HOL/Library/simps_case_conv.ML
changeset 59582 0fbed69ff081
parent 59580 cbc38731d42f
child 59621 291934bac95e
equal deleted inserted replaced
59580:cbc38731d42f 59582:0fbed69ff081
    25 fun get_split_ths ctxt = collect_Tcons
    25 fun get_split_ths ctxt = collect_Tcons
    26     #> distinct (op =)
    26     #> distinct (op =)
    27     #> map_filter (Ctr_Sugar.ctr_sugar_of ctxt)
    27     #> map_filter (Ctr_Sugar.ctr_sugar_of ctxt)
    28     #> map #split
    28     #> map #split
    29 
    29 
    30 val strip_eq = prop_of #> HOLogic.dest_Trueprop #> HOLogic.dest_eq
    30 val strip_eq = Thm.prop_of #> HOLogic.dest_Trueprop #> HOLogic.dest_eq
    31 
    31 
    32 
    32 
    33 local
    33 local
    34 
    34 
    35   fun transpose [] = []
    35   fun transpose [] = []
   159   in forall (is_free_eq_imp o dest_alls) (get_conjs t) end
   159   in forall (is_free_eq_imp o dest_alls) (get_conjs t) end
   160   handle TERM _ => false
   160   handle TERM _ => false
   161 
   161 
   162 fun apply_split ctxt split thm = Seq.of_list
   162 fun apply_split ctxt split thm = Seq.of_list
   163   let val ((_,thm'), ctxt') = Variable.import false [thm] ctxt in
   163   let val ((_,thm'), ctxt') = Variable.import false [thm] ctxt in
   164     (Variable.export ctxt' ctxt) (filter (was_split o prop_of) (thm' RL [split]))
   164     (Variable.export ctxt' ctxt) (filter (was_split o Thm.prop_of) (thm' RL [split]))
   165   end
   165   end
   166 
   166 
   167 fun forward_tac rules t = Seq.of_list ([t] RL rules)
   167 fun forward_tac rules t = Seq.of_list ([t] RL rules)
   168 
   168 
   169 val refl_imp = refl RSN (2, mp)
   169 val refl_imp = refl RSN (2, mp)
   174     THEN (forward_tac [refl_imp])
   174     THEN (forward_tac [refl_imp])
   175 
   175 
   176 fun do_split ctxt split =
   176 fun do_split ctxt split =
   177   let
   177   let
   178     val split' = split RS iffD1;
   178     val split' = split RS iffD1;
   179     val split_rhs = concl_of (hd (snd (fst (Variable.import false [split'] ctxt))))
   179     val split_rhs = Thm.concl_of (hd (snd (fst (Variable.import false [split'] ctxt))))
   180   in if was_split split_rhs
   180   in if was_split split_rhs
   181      then DETERM (apply_split ctxt split') THEN get_rules_once_split
   181      then DETERM (apply_split ctxt split') THEN get_rules_once_split
   182      else raise TERM ("malformed split rule", [split_rhs])
   182      else raise TERM ("malformed split rule", [split_rhs])
   183   end
   183   end
   184 
   184