src/Pure/Isar/code.ML
changeset 28353 40306cc4d16a
parent 28350 715163ec93c0
child 28359 bd4750bcb4e6
equal deleted inserted replaced
28352:cab797b79421 28353:40306cc4d16a
   771 (** post- and preprocessing **)
   771 (** post- and preprocessing **)
   772 
   772 
   773 local
   773 local
   774 
   774 
   775 fun apply_functrans thy [] = []
   775 fun apply_functrans thy [] = []
   776   | apply_functrans thy (thms as thm :: _) =
   776   | apply_functrans thy (thms as (thm, _) :: _) =
   777       let
   777       let
   778         val const = const_of_func thy thm;
   778         val const = const_of_func thy thm;
   779         val functrans = (map (fn (_, (_, f)) => f thy) o #functrans
   779         val functrans = (map (fn (_, (_, f)) => f thy) o #functrans
   780           o the_thmproc o the_exec) thy;
   780           o the_thmproc o the_exec) thy;
   781         val thms' = perhaps (perhaps_loop (perhaps_apply functrans)) thms;
   781         val thms' = perhaps (perhaps_loop (perhaps_apply functrans)) (map fst thms);
   782       in certify_const thy const thms' end;
   782         val thms'' = certify_const thy const thms';
       
   783         val linears = map snd thms;
       
   784       in (*FIXME temporary workaround*) if length thms'' = length linears
       
   785         then thms'' ~~ linears
       
   786         else map (rpair true) thms''
       
   787       end;
   783 
   788 
   784 fun rhs_conv conv thm =
   789 fun rhs_conv conv thm =
   785   let
   790   let
   786     val thm' = (conv o Thm.rhs_of) thm;
   791     val thm' = (conv o Thm.rhs_of) thm;
   787   in Thm.transitive thm thm' end
   792   in Thm.transitive thm thm' end
   799   let
   804   let
   800     val pre = (Simplifier.theory_context thy o #pre o the_thmproc o the_exec) thy;
   805     val pre = (Simplifier.theory_context thy o #pre o the_thmproc o the_exec) thy;
   801   in
   806   in
   802     thms
   807     thms
   803     |> apply_functrans thy
   808     |> apply_functrans thy
   804     |> map (Code_Unit.rewrite_func pre)
   809     |> (map o apfst) (Code_Unit.rewrite_func pre)
   805     (*FIXME - must check here: rewrite rule, defining equation, proper constant *)
   810     (*FIXME - must check here: rewrite rule, defining equation, proper constant *)
   806     |> map (AxClass.unoverload thy)
   811     |> (map o apfst) (AxClass.unoverload thy)
   807     |> common_typ_funcs
   812     |> burrow_fst common_typ_funcs
   808   end;
   813   end;
   809 
   814 
   810 
   815 
   811 fun preprocess_conv ct =
   816 fun preprocess_conv ct =
   812   let
   817   let
   856   let
   861   let
   857     fun drop_refl thy = filter_out (is_equal o Term.fast_term_ord o Logic.dest_equals
   862     fun drop_refl thy = filter_out (is_equal o Term.fast_term_ord o Logic.dest_equals
   858       o ObjectLogic.drop_judgment thy o Thm.plain_prop_of o fst);
   863       o ObjectLogic.drop_judgment thy o Thm.plain_prop_of o fst);
   859   in
   864   in
   860     get_funcs thy const
   865     get_funcs thy const
   861     |> burrow_fst (preprocess thy)
   866     |> preprocess thy
   862     |> drop_refl thy
   867     |> drop_refl thy
   863   end;
   868   end;
   864 
   869 
   865 fun default_typ thy c = case default_typ_proto thy c
   870 fun default_typ thy c = case default_typ_proto thy c
   866  of SOME ty => Code_Unit.typscheme thy (c, ty)
   871  of SOME ty => Code_Unit.typscheme thy (c, ty)