43 if rhs aconv rhs' then target_notation prmode [(Const lhs, mx)] Morphism.identity |
43 if rhs aconv rhs' then target_notation prmode [(Const lhs, mx)] Morphism.identity |
44 else I) |
44 else I) |
45 else I |
45 else I |
46 end; |
46 end; |
47 |
47 |
48 fun abbrevs prmode raw_args lthy = |
48 fun abbrev prmode raw_arg lthy = |
49 let |
49 let |
50 val is_local = is_none o Sign.const_constraint (ProofContext.theory_of lthy); |
50 val is_local = is_none o Sign.const_constraint (ProofContext.theory_of lthy); |
51 val local_term = Term.exists_subterm (fn Const (c, _) => is_local c | _ => false); |
51 val local_term = Term.exists_subterm (fn Const (c, _) => is_local c | _ => false); |
52 val input_only = (#1 Syntax.input_mode, #2 prmode); |
52 val input_only = (#1 Syntax.input_mode, #2 prmode); |
53 val expand = ProofContext.cert_term (ProofContext.expand_abbrevs true lthy); |
53 val expand = ProofContext.cert_term (ProofContext.set_expand_abbrevs true lthy); |
54 val args = raw_args |> map (morph_abbrev (LocalTheory.target_morphism lthy) #> |
54 val arg = raw_arg |> (morph_abbrev (LocalTheory.target_morphism lthy) #> |
55 (fn (lhs, rhs) => (*avoid dynamic references to local names*) |
55 (fn (lhs, rhs) => (*avoid dynamic references to local names*) |
56 if local_term rhs then (input_only, (lhs, expand rhs)) |
56 if local_term rhs then (input_only, (lhs, expand rhs)) |
57 else (prmode, (lhs, rhs)))); |
57 else (prmode, (lhs, rhs)))); |
58 in LocalTheory.term_syntax (fn phi => fold (fn arg => target_abbrev arg phi) args) lthy end; |
58 in LocalTheory.term_syntax (fn phi => target_abbrev arg phi) lthy end; |
59 |
59 |
60 end; |
60 end; |