src/HOL/Tools/split_rule.ML
changeset 58468 d1f6a38f9415
parent 51717 9e7d1c139569
child 58820 3ad2759acc52
equal deleted inserted replaced
58467:6a3da58f7233 58468:d1f6a38f9415
    35       internal_split_const (T1, T2, T3) $
    35       internal_split_const (T1, T2, T3) $
    36       Abs ("v", T1,
    36       Abs ("v", T1,
    37           ap_split T2 T3
    37           ap_split T2 T3
    38              ((ap_split T1 (HOLogic.flatten_tupleT T2 ---> T3) (incr_boundvars 1 u)) $
    38              ((ap_split T1 (HOLogic.flatten_tupleT T2 ---> T3) (incr_boundvars 1 u)) $
    39               Bound 0))
    39               Bound 0))
    40   | ap_split T T3 u = u;
    40   | ap_split _ T3 u = u;
    41 
    41 
    42 (*Curries any Var of function type in the rule*)
    42 (*Curries any Var of function type in the rule*)
    43 fun split_rule_var' (t as Var (v, Type ("fun", [T1, T2]))) rl =
    43 fun split_rule_var' (t as Var (v, Type ("fun", [T1, T2]))) rl =
    44       let val T' = HOLogic.flatten_tupleT T1 ---> T2;
    44       let val T' = HOLogic.flatten_tupleT T1 ---> T2;
    45           val newt = ap_split T1 T2 (Var (v, T'));
    45           val newt = ap_split T1 T2 (Var (v, T'));
    46           val cterm = Thm.cterm_of (Thm.theory_of_thm rl);
    46           val cterm = Thm.cterm_of (Thm.theory_of_thm rl);
    47       in Thm.instantiate ([], [(cterm t, cterm newt)]) rl end
    47       in Thm.instantiate ([], [(cterm t, cterm newt)]) rl end
    48   | split_rule_var' t rl = rl;
    48   | split_rule_var' _ rl = rl;
    49 
    49 
    50 
    50 
    51 (* complete splitting of partially split rules *)
    51 (* complete splitting of partially split rules *)
    52 
    52 
    53 fun ap_split' (T::Ts) U u = Abs ("v", T, ap_split' Ts U
    53 fun ap_split' (T::Ts) U u = Abs ("v", T, ap_split' Ts U
    80 
    80 
    81 fun collect_vars (Abs (_, _, t)) = collect_vars t
    81 fun collect_vars (Abs (_, _, t)) = collect_vars t
    82   | collect_vars t =
    82   | collect_vars t =
    83       (case strip_comb t of
    83       (case strip_comb t of
    84         (v as Var _, ts) => cons (v, ts)
    84         (v as Var _, ts) => cons (v, ts)
    85       | (t, ts) => fold collect_vars ts);
    85       | (_, ts) => fold collect_vars ts);
    86 
    86 
    87 
    87 
    88 fun split_rule_var ctxt =
    88 fun split_rule_var ctxt =
    89   (Drule.export_without_context o remove_internal_split ctxt) oo split_rule_var';
    89   (Drule.export_without_context o remove_internal_split ctxt) oo split_rule_var';
    90 
    90