64 let |
64 let |
65 val { primary_constraints, secondary_constraints, improve, subst, passed, ... } = |
65 val { primary_constraints, secondary_constraints, improve, subst, passed, ... } = |
66 ImprovableSyntax.get ctxt; |
66 ImprovableSyntax.get ctxt; |
67 val tsig = (Sign.tsig_of o ProofContext.theory_of) ctxt; |
67 val tsig = (Sign.tsig_of o ProofContext.theory_of) ctxt; |
68 fun accumulate_improvements (Const (c, ty)) = (case improve (c, ty) |
68 fun accumulate_improvements (Const (c, ty)) = (case improve (c, ty) |
69 of SOME ty_ty' => (perhaps o try o Type.typ_match tsig) ty_ty' |
69 of SOME ty_ty' => Type.typ_match tsig ty_ty' |
70 | _ => I) |
70 | _ => I) |
71 | accumulate_improvements _ = I; |
71 | accumulate_improvements _ = I; |
72 val improvements = (fold o fold_aterms) accumulate_improvements ts Vartab.empty; |
72 val improvements = (fold o fold_aterms) accumulate_improvements ts Vartab.empty; |
73 val ts' = (map o map_types) (Envir.typ_subst_TVars improvements) ts; |
73 val ts' = (map o map_types) (Envir.typ_subst_TVars improvements) ts; |
74 fun apply_subst t = Envir.expand_term (fn Const (c, ty) => (case subst (c, ty) |
74 fun apply_subst t = Envir.expand_term (fn Const (c, ty) => (case subst (c, ty) |