46 passed = true |
46 passed = true |
47 }; |
47 }; |
48 ); |
48 ); |
49 |
49 |
50 fun map_improvable_syntax f = ImprovableSyntax.map (fn { primary_constraints, |
50 fun map_improvable_syntax f = ImprovableSyntax.map (fn { primary_constraints, |
51 secondary_constraints, improve, subst, consider_abbrevs, unchecks, passed } => let |
51 secondary_constraints, improve, subst, consider_abbrevs, unchecks, passed } => |
|
52 let |
52 val (((primary_constraints', secondary_constraints'), |
53 val (((primary_constraints', secondary_constraints'), |
53 (((improve', subst'), consider_abbrevs'), unchecks')), passed') |
54 (((improve', subst'), consider_abbrevs'), unchecks')), passed') |
54 = f (((primary_constraints, secondary_constraints), |
55 = f (((primary_constraints, secondary_constraints), |
55 (((improve, subst), consider_abbrevs), unchecks)), passed) |
56 (((improve, subst), consider_abbrevs), unchecks)), passed) |
56 in { primary_constraints = primary_constraints', secondary_constraints = secondary_constraints', |
57 in { primary_constraints = primary_constraints', secondary_constraints = secondary_constraints', |
57 improve = improve', subst = subst', consider_abbrevs = consider_abbrevs', |
58 improve = improve', subst = subst', consider_abbrevs = consider_abbrevs', |
58 unchecks = unchecks', passed = passed' |
59 unchecks = unchecks', passed = passed' } |
59 } end); |
60 end); |
60 |
61 |
61 val mark_passed = (map_improvable_syntax o apsnd) (K true); |
62 val mark_passed = (map_improvable_syntax o apsnd) (K true); |
62 |
63 |
63 fun improve_term_check ts ctxt = |
64 fun improve_term_check ts ctxt = |
64 let |
65 let |
78 if Type.typ_instance tsig (ty, ty') |
79 if Type.typ_instance tsig (ty, ty') |
79 then SOME (ty', apply_subst t') else NONE |
80 then SOME (ty', apply_subst t') else NONE |
80 | NONE => NONE) |
81 | NONE => NONE) |
81 | _ => NONE) t; |
82 | _ => NONE) t; |
82 val ts'' = if is_abbrev then ts' else map apply_subst ts'; |
83 val ts'' = if is_abbrev then ts' else map apply_subst ts'; |
83 in if eq_list (op aconv) (ts, ts'') andalso passed_or_abbrev then NONE else |
84 in |
|
85 if eq_list (op aconv) (ts, ts'') andalso passed_or_abbrev then NONE else |
84 if passed_or_abbrev then SOME (ts'', ctxt) |
86 if passed_or_abbrev then SOME (ts'', ctxt) |
85 else SOME (ts'', ctxt |
87 else SOME (ts'', ctxt |
86 |> fold (ProofContext.add_const_constraint o apsnd SOME) secondary_constraints |
88 |> fold (ProofContext.add_const_constraint o apsnd SOME) secondary_constraints |
87 |> mark_passed) |
89 |> mark_passed) |
88 end; |
90 end; |
164 in Pretty.str "overloading" :: map pr_operation overloading end; |
166 in Pretty.str "overloading" :: map pr_operation overloading end; |
165 |
167 |
166 fun conclude lthy = |
168 fun conclude lthy = |
167 let |
169 let |
168 val overloading = get_overloading lthy; |
170 val overloading = get_overloading lthy; |
169 val _ = if null overloading then () else |
171 val _ = |
170 error ("Missing definition(s) for parameter(s) " ^ commas (map (quote |
172 if null overloading then () |
171 o Syntax.string_of_term lthy o Const o fst) overloading)); |
173 else |
|
174 error ("Missing definition(s) for parameter(s) " ^ commas (map (quote |
|
175 o Syntax.string_of_term lthy o Const o fst) overloading)); |
172 in lthy end; |
176 in lthy end; |
173 |
177 |
174 fun gen_overloading prep_const raw_overloading thy = |
178 fun gen_overloading prep_const raw_overloading thy = |
175 let |
179 let |
176 val ctxt = ProofContext.init_global thy; |
180 val ctxt = ProofContext.init_global thy; |