28 val prove_freeness: theory -> tactic -> string |
28 val prove_freeness: theory -> tactic -> string |
29 -> (string * sort) list * (string * typ list) list -> thm list; |
29 -> (string * sort) list * (string * typ list) list -> thm list; |
30 |
30 |
31 type thmtab; |
31 type thmtab; |
32 val mk_thmtab: theory -> (string * typ) list -> thmtab; |
32 val mk_thmtab: theory -> (string * typ) list -> thmtab; |
33 val get_sortalgebra: thmtab -> Sorts.algebra; |
|
34 val get_dtyp_of_cons: thmtab -> string * typ -> string option; |
33 val get_dtyp_of_cons: thmtab -> string * typ -> string option; |
35 val get_dtyp_spec: thmtab -> string |
34 val get_dtyp_spec: thmtab -> string |
36 -> ((string * sort) list * (string * typ list) list) option; |
35 -> ((string * sort) list * (string * typ list) list) option; |
37 val get_fun_thms: thmtab -> string * typ -> thm list; |
36 val get_fun_thms: thmtab -> string * typ -> thm list; |
38 |
37 |
747 end; |
746 end; |
748 |
747 |
749 structure Consttab = CodegenConsts.Consttab; |
748 structure Consttab = CodegenConsts.Consttab; |
750 type thmtab = (theory * (thm list Consttab.table |
749 type thmtab = (theory * (thm list Consttab.table |
751 * string Consttab.table) |
750 * string Consttab.table) |
752 * (Sorts.algebra * ((string * sort) list * (string * typ list) list) Symtab.table)); |
751 * ((string * sort) list * (string * typ list) list) Symtab.table); |
753 |
752 |
754 fun thmtab_empty thy = (thy, (Consttab.empty, Consttab.empty), |
753 fun thmtab_empty thy = (thy, (Consttab.empty, Consttab.empty), |
755 (ClassPackage.operational_algebra thy, Symtab.empty)); |
754 Symtab.empty); |
756 |
|
757 fun get_sortalgebra (_, _, (algebra, _)) = |
|
758 algebra; |
|
759 |
755 |
760 fun get_dtyp_of_cons (thy, (_, dtcotab), _) = |
756 fun get_dtyp_of_cons (thy, (_, dtcotab), _) = |
761 Consttab.lookup dtcotab o CodegenConsts.norminst_of_typ thy; |
757 Consttab.lookup dtcotab o CodegenConsts.norminst_of_typ thy; |
762 |
758 |
763 fun get_dtyp_spec (_, _, (_, dttab)) = |
759 fun get_dtyp_spec (_, _, dttab) = |
764 Symtab.lookup dttab; |
760 Symtab.lookup dttab; |
765 |
761 |
766 fun has_fun_thms (thy, (funtab, _), _) = |
762 fun has_fun_thms (thy, (funtab, _), _) = |
767 is_some o Consttab.lookup funtab o CodegenConsts.norminst_of_typ thy; |
763 is_some o Consttab.lookup funtab o CodegenConsts.norminst_of_typ thy; |
768 |
764 |
859 |> Consttab.keys; |
855 |> Consttab.keys; |
860 fun add_dtyps_of_type ty thmtab = |
856 fun add_dtyps_of_type ty thmtab = |
861 let |
857 let |
862 val tycos = add_tycos ty []; |
858 val tycos = add_tycos ty []; |
863 val tycos_new = filter (is_none o get_dtyp_spec thmtab) tycos; |
859 val tycos_new = filter (is_none o get_dtyp_spec thmtab) tycos; |
864 fun add_dtyp_spec dtco (dtyp_spec as (vs, cs)) ((thy, (funtab, dtcotab), (algebra, dttab))) = |
860 fun add_dtyp_spec dtco (dtyp_spec as (vs, cs)) ((thy, (funtab, dtcotab), dttab)) = |
865 let |
861 let |
866 fun mk_co (c, tys) = |
862 fun mk_co (c, tys) = |
867 CodegenConsts.norminst_of_typ thy (c, Logic.varifyT (tys ---> Type (dtco, map TFree vs))); |
863 CodegenConsts.norminst_of_typ thy (c, Logic.varifyT (tys ---> Type (dtco, map TFree vs))); |
868 in |
864 in |
869 (thy, (funtab, dtcotab |> fold (fn c_tys => |
865 (thy, (funtab, dtcotab |> fold (fn c_tys => |
870 Consttab.update_new (mk_co c_tys, dtco)) cs), |
866 Consttab.update_new (mk_co c_tys, dtco)) cs), |
871 (algebra, dttab |> Symtab.update_new (dtco, dtyp_spec))) |
867 dttab |> Symtab.update_new (dtco, dtyp_spec)) |
872 end; |
868 end; |
873 in |
869 in |
874 thmtab |
870 thmtab |
875 |> fold (fn tyco => case get_datatypes thy tyco |
871 |> fold (fn tyco => case get_datatypes thy tyco |
876 of SOME (dtyp_spec, _) => add_dtyp_spec tyco dtyp_spec |
872 of SOME (dtyp_spec, _) => add_dtyp_spec tyco dtyp_spec |