src/HOL/Tools/Function/partial_function.ML
changeset 42361 23f352990944
parent 42083 e1209fc7ecdc
child 42388 a44b0fdaa6c2
equal deleted inserted replaced
42360:da8817d01e7c 42361:23f352990944
    81 
    81 
    82 (*split on case expressions*)
    82 (*split on case expressions*)
    83 val split_cases_tac = Subgoal.FOCUS_PARAMS (fn {context=ctxt, ...} =>
    83 val split_cases_tac = Subgoal.FOCUS_PARAMS (fn {context=ctxt, ...} =>
    84   SUBGOAL (fn (t, i) => case t of
    84   SUBGOAL (fn (t, i) => case t of
    85     _ $ (_ $ Abs (_, _, body)) =>
    85     _ $ (_ $ Abs (_, _, body)) =>
    86       (case dest_case (ProofContext.theory_of ctxt) body of
    86       (case dest_case (Proof_Context.theory_of ctxt) body of
    87          NONE => no_tac
    87          NONE => no_tac
    88        | SOME (arg, conv) =>
    88        | SOME (arg, conv) =>
    89            let open Conv in
    89            let open Conv in
    90               if Term.is_open arg then no_tac
    90               if Term.is_open arg then no_tac
    91               else ((DETERM o strip_cases o Induct.cases_tac ctxt false [[SOME arg]] NONE [])
    91               else ((DETERM o strip_cases o Induct.cases_tac ctxt false [[SOME arg]] NONE [])
   120 
   120 
   121 (*Returns t $ u, but instantiates the type of t to make the
   121 (*Returns t $ u, but instantiates the type of t to make the
   122 application type correct*)
   122 application type correct*)
   123 fun apply_inst ctxt t u =
   123 fun apply_inst ctxt t u =
   124   let
   124   let
   125     val thy = ProofContext.theory_of ctxt;
   125     val thy = Proof_Context.theory_of ctxt;
   126     val T = domain_type (fastype_of t);
   126     val T = domain_type (fastype_of t);
   127     val T' = fastype_of u;
   127     val T' = fastype_of u;
   128     val subst = Type.typ_match (Sign.tsig_of thy) (T, T') Vartab.empty
   128     val subst = Type.typ_match (Sign.tsig_of thy) (T, T') Vartab.empty
   129       handle Type.TYPE_MATCH => raise TYPE ("apply_inst", [T, T'], [t, u])
   129       handle Type.TYPE_MATCH => raise TYPE ("apply_inst", [T, T'], [t, u])
   130   in
   130   in
   168     val ((_, plain_eqn), _) = Function_Lib.focus_term eqn lthy;
   168     val ((_, plain_eqn), _) = Function_Lib.focus_term eqn lthy;
   169 
   169 
   170     val ((f_binding, fT), mixfix) = the_single fixes;
   170     val ((f_binding, fT), mixfix) = the_single fixes;
   171     val fname = Binding.name_of f_binding;
   171     val fname = Binding.name_of f_binding;
   172 
   172 
   173     val cert = cterm_of (ProofContext.theory_of lthy);
   173     val cert = cterm_of (Proof_Context.theory_of lthy);
   174     val (lhs, rhs) = HOLogic.dest_eq (HOLogic.dest_Trueprop plain_eqn);
   174     val (lhs, rhs) = HOLogic.dest_eq (HOLogic.dest_Trueprop plain_eqn);
   175     val (head, args) = strip_comb lhs;
   175     val (head, args) = strip_comb lhs;
   176     val F = fold_rev lambda (head :: args) rhs;
   176     val F = fold_rev lambda (head :: args) rhs;
   177 
   177 
   178     val arity = length args;
   178     val arity = length args;