81 |
81 |
82 fun const ((c, T), mx) thy = |
82 fun const ((c, T), mx) thy = |
83 let |
83 let |
84 val U = map #2 xs ---> T; |
84 val U = map #2 xs ---> T; |
85 val t = Term.list_comb (Const (Sign.full_name thy c, U), map Free xs); |
85 val t = Term.list_comb (Const (Sign.full_name thy c, U), map Free xs); |
86 val (mx1, mx2) = ClassPackage.fork_mixfix is_loc some_class mx; |
86 val (mx1, mx2) = Class.fork_mixfix is_loc some_class mx; |
87 val thy' = Sign.add_consts_authentic [(c, U, mx1)] thy; |
87 val thy' = Sign.add_consts_authentic [(c, U, mx1)] thy; |
88 in (((c, mx2), t), thy') end; |
88 in (((c, mx2), t), thy') end; |
89 |
89 |
90 fun const_class (SOME class) ((c, _), mx) (_, t) = |
90 fun const_class (SOME class) ((c, _), mx) (_, t) = |
91 ClassPackage.add_const_in_class class ((c, t), mx) |
91 Class.add_const_in_class class ((c, t), mx) |
92 | const_class NONE _ _ = I; |
92 | const_class NONE _ _ = I; |
93 |
93 |
94 val (abbrs, lthy') = lthy |
94 val (abbrs, lthy') = lthy |
95 |> LocalTheory.theory_result (fold_map const decls) |
95 |> LocalTheory.theory_result (fold_map const decls) |
96 val defs = map (apsnd (pair ("", []))) abbrs; |
96 val defs = map (apsnd (pair ("", []))) abbrs; |
134 val U = Term.fastype_of u; |
134 val U = Term.fastype_of u; |
135 val u' = singleton (Variable.export_terms (Variable.declare_term u target) thy_ctxt) u; |
135 val u' = singleton (Variable.export_terms (Variable.declare_term u target) thy_ctxt) u; |
136 |
136 |
137 val ((lhs as Const (full_c, _), rhs), lthy1) = lthy |
137 val ((lhs as Const (full_c, _), rhs), lthy1) = lthy |
138 |> LocalTheory.theory_result (Sign.add_abbrev (#1 prmode) (c, u')); |
138 |> LocalTheory.theory_result (Sign.add_abbrev (#1 prmode) (c, u')); |
139 val (mx1, mx2) = ClassPackage.fork_mixfix is_loc some_class mx; |
139 val (mx1, mx2) = Class.fork_mixfix is_loc some_class mx; |
140 in |
140 in |
141 lthy1 |
141 lthy1 |
142 |> LocalTheory.theory (Sign.add_notation prmode [(lhs, mx1)]) |
142 |> LocalTheory.theory (Sign.add_notation prmode [(lhs, mx1)]) |
143 |> is_loc ? internal_abbrev prmode ((c, mx2), Term.list_comb (Const (full_c, U), xs)) |
143 |> is_loc ? internal_abbrev prmode ((c, mx2), Term.list_comb (Const (full_c, U), xs)) |
144 |> local_abbrev (c, rhs) |
144 |> local_abbrev (c, rhs) |
339 |
339 |
340 fun begin loc ctxt = |
340 fun begin loc ctxt = |
341 let |
341 let |
342 val thy = ProofContext.theory_of ctxt; |
342 val thy = ProofContext.theory_of ctxt; |
343 val is_loc = loc <> ""; |
343 val is_loc = loc <> ""; |
344 val some_class = ClassPackage.class_of_locale thy loc; |
344 val some_class = Class.class_of_locale thy loc; |
345 in |
345 in |
346 ctxt |
346 ctxt |
347 |> Data.put (if is_loc then SOME loc else NONE) |
347 |> Data.put (if is_loc then SOME loc else NONE) |
348 |> LocalTheory.init (NameSpace.base loc) |
348 |> LocalTheory.init (NameSpace.base loc) |
349 {pretty = pretty loc, |
349 {pretty = pretty loc, |