125 struct |
125 struct |
126 |
126 |
127 fun legacy_unvarifyT thm = |
127 fun legacy_unvarifyT thm = |
128 let |
128 let |
129 val cT = Thm.ctyp_of (Thm.theory_of_thm thm); |
129 val cT = Thm.ctyp_of (Thm.theory_of_thm thm); |
130 val tvars = rev (Drule.fold_terms Term.add_tvars thm []); |
130 val tvars = rev (Thm.fold_terms Term.add_tvars thm []); |
131 val tfrees = map (fn ((x, _), S) => SOME (cT (TFree (x, S)))) tvars; |
131 val tfrees = map (fn ((x, _), S) => SOME (cT (TFree (x, S)))) tvars; |
132 in Drule.instantiate' tfrees [] thm end; |
132 in Drule.instantiate' tfrees [] thm end; |
133 |
133 |
134 fun legacy_unvarify raw_thm = |
134 fun legacy_unvarify raw_thm = |
135 let |
135 let |
136 val thm = legacy_unvarifyT raw_thm; |
136 val thm = legacy_unvarifyT raw_thm; |
137 val ct = Thm.cterm_of (Thm.theory_of_thm thm); |
137 val ct = Thm.cterm_of (Thm.theory_of_thm thm); |
138 val vars = rev (Drule.fold_terms Term.add_vars thm []); |
138 val vars = rev (Thm.fold_terms Term.add_vars thm []); |
139 val frees = map (fn ((x, _), T) => SOME (ct (Free (x, T)))) vars; |
139 val frees = map (fn ((x, _), T) => SOME (ct (Free (x, T)))) vars; |
140 in Drule.instantiate' [] frees thm end; |
140 in Drule.instantiate' [] frees thm end; |
141 |
141 |
142 |
142 |
143 (** locale elements and expressions **) |
143 (** locale elements and expressions **) |
741 val new_parms = map (Element.rename ren) parms' |> distinct (op =); |
741 val new_parms = map (Element.rename ren) parms' |> distinct (op =); |
742 val ren_syn = syn' |> Symtab.dest |> map (Element.rename_var ren); |
742 val ren_syn = syn' |> Symtab.dest |> map (Element.rename_var ren); |
743 val new_syn = fold (Symtab.insert (op =)) ren_syn Symtab.empty |
743 val new_syn = fold (Symtab.insert (op =)) ren_syn Symtab.empty |
744 handle Symtab.DUP x => |
744 handle Symtab.DUP x => |
745 err_in_expr ctxt ("Conflicting syntax for parameter: " ^ quote x) expr; |
745 err_in_expr ctxt ("Conflicting syntax for parameter: " ^ quote x) expr; |
746 val syn_types = map (apsnd (fn mx => SOME (Type.freeze_type (#1 (TypeInfer.paramify_dummies (TypeInfer.mixfixT mx) 0))))) (Symtab.dest new_syn); |
746 val syn_types = map (apsnd (fn mx => |
|
747 SOME (Type.freeze_type (#1 (TypeInfer.paramify_dummies (Syntax.mixfixT mx) 0))))) |
|
748 (Symtab.dest new_syn); |
747 val ren_types = types' |> Symtab.dest |> map (apfst (Element.rename ren)); |
749 val ren_types = types' |> Symtab.dest |> map (apfst (Element.rename ren)); |
748 val (env :: _) = unify_parms ctxt [] |
750 val (env :: _) = unify_parms ctxt [] |
749 ((ren_types |> map (apsnd SOME)) :: map single syn_types); |
751 ((ren_types |> map (apsnd SOME)) :: map single syn_types); |
750 val new_types = fold (Symtab.insert (op =)) |
752 val new_types = fold (Symtab.insert (op =)) |
751 (map (apsnd (Element.instT_type env)) ren_types) Symtab.empty; |
753 (map (apsnd (Element.instT_type env)) ren_types) Symtab.empty; |