9 type improvable_syntax |
9 type improvable_syntax |
10 val activate_improvable_syntax: Proof.context -> Proof.context |
10 val activate_improvable_syntax: Proof.context -> Proof.context |
11 val map_improvable_syntax: (improvable_syntax -> improvable_syntax) |
11 val map_improvable_syntax: (improvable_syntax -> improvable_syntax) |
12 -> Proof.context -> Proof.context |
12 -> Proof.context -> Proof.context |
13 val set_primary_constraints: Proof.context -> Proof.context |
13 val set_primary_constraints: Proof.context -> Proof.context |
|
14 val show_reverted_improvements: bool Config.T; |
14 |
15 |
15 val overloading: (string * (string * typ) * bool) list -> theory -> local_theory |
16 val overloading: (string * (string * typ) * bool) list -> theory -> local_theory |
16 val overloading_cmd: (string * string * bool) list -> theory -> local_theory |
17 val overloading_cmd: (string * string * bool) list -> theory -> local_theory |
17 end; |
18 end; |
18 |
19 |
88 fun rewrite_liberal thy unchecks t = |
89 fun rewrite_liberal thy unchecks t = |
89 (case try (Pattern.rewrite_term thy unchecks []) t of |
90 (case try (Pattern.rewrite_term thy unchecks []) t of |
90 NONE => NONE |
91 NONE => NONE |
91 | SOME t' => if t aconv t' then NONE else SOME t'); |
92 | SOME t' => if t aconv t' then NONE else SOME t'); |
92 |
93 |
|
94 val show_reverted_improvements = |
|
95 Attrib.setup_config_bool @{binding "show_reverted_improvements"} (K true); |
|
96 |
93 fun improve_term_uncheck ts ctxt = |
97 fun improve_term_uncheck ts ctxt = |
94 let |
98 let |
95 val thy = Proof_Context.theory_of ctxt; |
99 val thy = Proof_Context.theory_of ctxt; |
96 val {syntax = {unchecks, ...}, ...} = Improvable_Syntax.get ctxt; |
100 val {syntax = {unchecks, ...}, ...} = Improvable_Syntax.get ctxt; |
|
101 val revert = Config.get ctxt show_reverted_improvements; |
97 val ts' = map (rewrite_liberal thy unchecks) ts; |
102 val ts' = map (rewrite_liberal thy unchecks) ts; |
98 in if exists is_some ts' then SOME (map2 the_default ts ts', ctxt) else NONE end; |
103 in if revert andalso exists is_some ts' then SOME (map2 the_default ts ts', ctxt) else NONE end; |
99 |
104 |
100 fun set_primary_constraints ctxt = |
105 fun set_primary_constraints ctxt = |
101 let |
106 let |
102 val {syntax = {primary_constraints, ...}, ...} = Improvable_Syntax.get ctxt; |
107 val {syntax = {primary_constraints, ...}, ...} = Improvable_Syntax.get ctxt; |
103 in fold (Proof_Context.add_const_constraint o apsnd SOME) primary_constraints ctxt end; |
108 in fold (Proof_Context.add_const_constraint o apsnd SOME) primary_constraints ctxt end; |