76 | Class of class * (vname * ((class * string) list * (string * itype) list)) |
76 | Class of class * (vname * ((class * string) list * (string * itype) list)) |
77 | Classrel of class * class |
77 | Classrel of class * class |
78 | Classparam of string * class |
78 | Classparam of string * class |
79 | Classinst of { class: string, tyco: string, vs: (vname * sort) list, |
79 | Classinst of { class: string, tyco: string, vs: (vname * sort) list, |
80 superinsts: (class * (string * (string * dict list list))) list, |
80 superinsts: (class * (string * (string * dict list list))) list, |
81 inst_params: ((string * const) * (thm * bool)) list, |
81 inst_params: ((string * (const * int)) * (thm * bool)) list, |
82 superinst_params: ((string * const) * (thm * bool)) list }; |
82 superinst_params: ((string * (const * int)) * (thm * bool)) list }; |
83 type program = stmt Graph.T |
83 type program = stmt Graph.T |
84 val empty_funs: program -> string list |
84 val empty_funs: program -> string list |
85 val map_terms_bottom_up: (iterm -> iterm) -> iterm -> iterm |
85 val map_terms_bottom_up: (iterm -> iterm) -> iterm -> iterm |
86 val map_terms_stmt: (iterm -> iterm) -> stmt -> stmt |
86 val map_terms_stmt: (iterm -> iterm) -> stmt -> stmt |
87 val is_constr: program -> string -> bool |
87 val is_constr: program -> string -> bool |
426 | Class of class * (vname * ((class * string) list * (string * itype) list)) |
426 | Class of class * (vname * ((class * string) list * (string * itype) list)) |
427 | Classrel of class * class |
427 | Classrel of class * class |
428 | Classparam of string * class |
428 | Classparam of string * class |
429 | Classinst of { class: string, tyco: string, vs: (vname * sort) list, |
429 | Classinst of { class: string, tyco: string, vs: (vname * sort) list, |
430 superinsts: (class * (string * (string * dict list list))) list, |
430 superinsts: (class * (string * (string * dict list list))) list, |
431 inst_params: ((string * const) * (thm * bool)) list, |
431 inst_params: ((string * (const * int)) * (thm * bool)) list, |
432 superinst_params: ((string * const) * (thm * bool)) list }; |
432 superinst_params: ((string * (const * int)) * (thm * bool)) list }; |
433 |
433 |
434 type program = stmt Graph.T; |
434 type program = stmt Graph.T; |
435 |
435 |
436 fun empty_funs program = |
436 fun empty_funs program = |
437 Graph.fold (fn (_, (Fun (c, ((_, []), _)), _)) => cons c | _ => I) program []; |
437 Graph.fold (fn (_, (Fun (c, ((_, []), _)), _)) => cons c | _ => I) program []; |
446 (ICase { term = map_terms_bottom_up f t, typ = ty, |
446 (ICase { term = map_terms_bottom_up f t, typ = ty, |
447 clauses = (map o pairself) (map_terms_bottom_up f) clauses, |
447 clauses = (map o pairself) (map_terms_bottom_up f) clauses, |
448 primitive = map_terms_bottom_up f t0 }); |
448 primitive = map_terms_bottom_up f t0 }); |
449 |
449 |
450 fun map_classparam_instances_as_term f = |
450 fun map_classparam_instances_as_term f = |
451 (map o apfst o apsnd) (fn const => case f (IConst const) of IConst const' => const') |
451 (map o apfst o apsnd o apfst) (fn const => case f (IConst const) of IConst const' => const') |
452 |
452 |
453 fun map_terms_stmt f NoStmt = NoStmt |
453 fun map_terms_stmt f NoStmt = NoStmt |
454 | map_terms_stmt f (Fun (c, ((tysm, eqs), case_cong))) = Fun (c, ((tysm, (map o apfst) |
454 | map_terms_stmt f (Fun (c, ((tysm, eqs), case_cong))) = Fun (c, ((tysm, (map o apfst) |
455 (fn (ts, t) => (map f ts, f t)) eqs), case_cong)) |
455 (fn (ts, t) => (map f ts, f t)) eqs), case_cong)) |
456 | map_terms_stmt f (stmt as Datatype _) = stmt |
456 | map_terms_stmt f (stmt as Datatype _) = stmt |
706 #>> (fn ((super_class, classrel), [Dict ([], Dict_Const (inst, dss))]) => |
706 #>> (fn ((super_class, classrel), [Dict ([], Dict_Const (inst, dss))]) => |
707 (super_class, (classrel, (inst, dss)))); |
707 (super_class, (classrel, (inst, dss)))); |
708 fun translate_classparam_instance (c, ty) = |
708 fun translate_classparam_instance (c, ty) = |
709 let |
709 let |
710 val raw_const = Const (c, map_type_tfree (K arity_typ') ty); |
710 val raw_const = Const (c, map_type_tfree (K arity_typ') ty); |
|
711 val dom_length = length (fst (strip_type ty)) |
711 val thm = Axclass.unoverload_conv thy (Thm.cterm_of thy raw_const); |
712 val thm = Axclass.unoverload_conv thy (Thm.cterm_of thy raw_const); |
712 val const = (apsnd Logic.unvarifyT_global o dest_Const o snd |
713 val const = (apsnd Logic.unvarifyT_global o dest_Const o snd |
713 o Logic.dest_equals o Thm.prop_of) thm; |
714 o Logic.dest_equals o Thm.prop_of) thm; |
714 in |
715 in |
715 ensure_const thy algbr eqngr permissive c |
716 ensure_const thy algbr eqngr permissive c |
716 ##>> translate_const thy algbr eqngr permissive (SOME thm) (const, NONE) |
717 ##>> translate_const thy algbr eqngr permissive (SOME thm) (const, NONE) |
717 #>> (fn (c, IConst const') => ((c, const'), (thm, true))) |
718 #>> (fn (c, IConst const') => ((c, (const', dom_length)), (thm, true))) |
718 end; |
719 end; |
719 val stmt_inst = |
720 val stmt_inst = |
720 ensure_class thy algbr eqngr permissive class |
721 ensure_class thy algbr eqngr permissive class |
721 ##>> ensure_tyco thy algbr eqngr permissive tyco |
722 ##>> ensure_tyco thy algbr eqngr permissive tyco |
722 ##>> fold_map (translate_tyvar_sort thy algbr eqngr permissive) vs |
723 ##>> fold_map (translate_tyvar_sort thy algbr eqngr permissive) vs |