src/HOL/Tools/BNF/bnf_lift.ML
changeset 62137 b8dc1fd7d900
parent 61841 4d3527b94f2a
child 62324 ae44f16dcea5
equal deleted inserted replaced
62136:c92d82c3f41b 62137:b8dc1fd7d900
   143     val zip_closed_F = Logic.all var_z imp_zip;
   143     val zip_closed_F = Logic.all var_z imp_zip;
   144 
   144 
   145     (* val wit_closed_F = @{term "wit_F a \<in> F"}; *)
   145     (* val wit_closed_F = @{term "wit_F a \<in> F"}; *)
   146     val (var_as, names_lthy) = mk_Frees "a" alphas names_lthy;
   146     val (var_as, names_lthy) = mk_Frees "a" alphas names_lthy;
   147     val (var_bs, _) = mk_Frees "a" alphas names_lthy;
   147     val (var_bs, _) = mk_Frees "a" alphas names_lthy;
       
   148     fun binder_types_until_eq V T =
       
   149       let
       
   150         fun strip (TU as Type ("fun", [T, U])) = if V = TU then [] else T :: strip U
       
   151           | strip T = if V = T then [] else
       
   152               error ("Bad type for witness: " ^ quote (Syntax.string_of_typ lthy T));
       
   153       in strip T end;
   148     val Iwits = the_default wits_F (Option.map (map (`(map (fn T =>
   154     val Iwits = the_default wits_F (Option.map (map (`(map (fn T =>
   149       find_index (fn U => T = U) alphas) o fst o strip_type o fastype_of))) wits);
   155       find_index (fn U => T = U) alphas) o binder_types_until_eq RepT o fastype_of))) wits);
   150     val wit_closed_Fs =
   156     val wit_closed_Fs =
   151       Iwits |> map (fn (I, wit_F) =>
   157       Iwits |> map (fn (I, wit_F) =>
   152         let
   158         let
   153           val vars = map (nth var_as) I;
   159           val vars = map (nth var_as) I;
   154           val wit_a = list_comb (wit_F, vars);
   160           val wit_a = list_comb (wit_F, vars);