src/Pure/Isar/locale.ML
author wenzelm
Tue Nov 06 01:18:46 2001 +0100 (2001-11-06)
changeset 12063 4c16bdee47d4
parent 12058 cc182b43dd55
child 12070 c72fe1edc9e7
permissions -rw-r--r--
added add_locale(_i) and store_thm;
removed old scope stuff;
tuned;
wenzelm@12014
     1
(*  Title:      Pure/Isar/locale.ML
wenzelm@11896
     2
    ID:         $Id$
wenzelm@11896
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@11896
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@11896
     5
wenzelm@12058
     6
Locales -- Isar proof contexts as meta-level predicates, with local
wenzelm@12063
     7
syntax and implicit structures.  Draws basic ideas from Florian
wenzelm@12063
     8
Kammueller's original version of locales, but uses the rich
wenzelm@12063
     9
infrastructure of Isar instead of the raw meta-logic.
wenzelm@11896
    10
wenzelm@11896
    11
TODO:
wenzelm@12063
    12
  - 'print_locales' command (also PG menu?);
wenzelm@12063
    13
  - cert_elem (do *not* cert_def, yet) (!?);
wenzelm@12063
    14
  - ensure unique defines;
wenzelm@12063
    15
  - local syntax (mostly in ProofContext);
wenzelm@11896
    16
*)
wenzelm@11896
    17
wenzelm@11896
    18
signature BASIC_LOCALE =
wenzelm@11896
    19
sig
wenzelm@11896
    20
  val print_locales: theory -> unit
wenzelm@12063
    21
  val print_locale: theory -> xstring -> unit
wenzelm@11896
    22
end;
wenzelm@11896
    23
wenzelm@11896
    24
signature LOCALE =
wenzelm@11896
    25
sig
wenzelm@11896
    26
  include BASIC_LOCALE
wenzelm@12046
    27
  type context
wenzelm@12014
    28
  type expression
wenzelm@12046
    29
  datatype ('typ, 'term, 'fact, 'att) elem =
wenzelm@12058
    30
    Fixes of (string * 'typ option * mixfix option) list |
wenzelm@12046
    31
    Assumes of ((string * 'att list) * ('term * ('term list * 'term list)) list) list |
wenzelm@12046
    32
    Defines of ((string * 'att list) * ('term * 'term list)) list |
wenzelm@12046
    33
    Notes of ((string * 'att list) * ('fact * 'att list) list) list |
wenzelm@12046
    34
    Uses of expression
wenzelm@12046
    35
  type 'att element
wenzelm@12046
    36
  type 'att element_i
wenzelm@12046
    37
  type locale
wenzelm@12046
    38
  val intern: Sign.sg -> xstring -> string
wenzelm@12014
    39
  val cond_extern: Sign.sg -> string -> xstring
wenzelm@12063
    40
  val attribute: ('att -> context attribute) ->
wenzelm@12046
    41
    ('typ, 'term, 'thm, 'att) elem -> ('typ, 'term, 'thm, context attribute) elem
wenzelm@12046
    42
  val activate_elements: context attribute element list -> context -> context
wenzelm@12046
    43
  val activate_elements_i: context attribute element_i list -> context -> context
wenzelm@12046
    44
  val activate_locale: xstring -> context -> context
wenzelm@12046
    45
  val activate_locale_i: string -> context -> context
wenzelm@12063
    46
  val add_locale: bstring -> xstring list -> context attribute element list -> theory -> theory
wenzelm@12063
    47
  val add_locale_i: bstring -> xstring list -> context attribute element_i list -> theory -> theory
wenzelm@12063
    48
  val store_thm: string -> (string * thm) * context attribute list -> theory -> theory
wenzelm@11896
    49
  val setup: (theory -> theory) list
wenzelm@11896
    50
end;
wenzelm@11896
    51
wenzelm@11896
    52
structure Locale: LOCALE =
wenzelm@11896
    53
struct
wenzelm@11896
    54
wenzelm@11896
    55
wenzelm@12014
    56
(** locale elements and locales **)
wenzelm@11896
    57
wenzelm@12014
    58
type context = ProofContext.context;
wenzelm@11896
    59
wenzelm@12014
    60
type expression = unit;  (* FIXME *)
wenzelm@11896
    61
wenzelm@12046
    62
datatype ('typ, 'term, 'fact, 'att) elem =
wenzelm@12058
    63
  Fixes of (string * 'typ option * mixfix option) list |
wenzelm@12046
    64
  Assumes of ((string * 'att list) * ('term * ('term list * 'term list)) list) list |
wenzelm@12046
    65
  Defines of ((string * 'att list) * ('term * 'term list)) list |
wenzelm@12046
    66
  Notes of ((string * 'att list) * ('fact * 'att list) list) list |
wenzelm@12014
    67
  Uses of expression;
wenzelm@11896
    68
wenzelm@12046
    69
type 'att element = (string, string, string, 'att) elem;
wenzelm@12046
    70
type 'att element_i = (typ, term, thm list, 'att) elem;
wenzelm@12063
    71
type locale = {imports: string list, elements: context attribute element_i list, closed: bool};
wenzelm@12063
    72
wenzelm@12063
    73
fun make_locale imports elements closed =
wenzelm@12063
    74
  {imports = imports, elements = elements, closed = closed}: locale;
wenzelm@12046
    75
wenzelm@12046
    76
wenzelm@12014
    77
fun fixes_of_elem (Fixes fixes) = map #1 fixes
wenzelm@12014
    78
  | fixes_of_elem _ = [];
wenzelm@11896
    79
wenzelm@12014
    80
fun frees_of_elem _ = [];  (* FIXME *)
wenzelm@11896
    81
wenzelm@12063
    82
(*fun close_locale {imports, elements, closed = _} = make_locale imports elements true;*)
wenzelm@12063
    83
fun close_locale x = x;   (* FIXME tmp *)
wenzelm@12063
    84
wenzelm@11896
    85
wenzelm@11896
    86
wenzelm@11896
    87
(** theory data **)
wenzelm@11896
    88
wenzelm@11896
    89
(* data kind 'Pure/locales' *)
wenzelm@11896
    90
wenzelm@11896
    91
structure LocalesArgs =
wenzelm@11896
    92
struct
wenzelm@12014
    93
  val name = "Isar/locales";
wenzelm@12063
    94
  type T = NameSpace.T * locale Symtab.table;
wenzelm@11896
    95
wenzelm@12063
    96
  val empty = (NameSpace.empty, Symtab.empty);
wenzelm@12063
    97
  val copy = I;
wenzelm@12063
    98
  fun prep_ext (space, locales) = (space, Symtab.map close_locale locales);
wenzelm@12063
    99
  fun merge ((space1, locales1), (space2, locales2)) =
wenzelm@12063
   100
      (NameSpace.merge (space1, space2), Symtab.merge (K true) (locales1, locales2));
wenzelm@11896
   101
wenzelm@12063
   102
  fun print _ (space, locales) =
wenzelm@12014
   103
    Pretty.strs ("locales:" :: map (NameSpace.cond_extern space o #1) (Symtab.dest locales))
wenzelm@12014
   104
    |> Pretty.writeln;
wenzelm@11896
   105
end;
wenzelm@11896
   106
wenzelm@11896
   107
structure LocalesData = TheoryDataFun(LocalesArgs);
wenzelm@11896
   108
val print_locales = LocalesData.print;
wenzelm@11896
   109
wenzelm@12063
   110
val intern = NameSpace.intern o #1 o LocalesData.get_sg;
wenzelm@12063
   111
val cond_extern = NameSpace.cond_extern o #1 o LocalesData.get_sg;
wenzelm@12014
   112
wenzelm@11896
   113
wenzelm@11896
   114
(* access locales *)
wenzelm@11896
   115
wenzelm@12063
   116
fun declare_locale name =
wenzelm@12063
   117
  LocalesData.map (apfst (fn space => (NameSpace.extend (space, [name]))));
wenzelm@11896
   118
wenzelm@12063
   119
fun put_locale name locale =
wenzelm@12063
   120
  LocalesData.map (apsnd (fn locales => Symtab.update ((name, locale), locales)));
wenzelm@12063
   121
wenzelm@12063
   122
fun get_locale thy name = Symtab.lookup (#2 (LocalesData.get thy), name);
wenzelm@11896
   123
wenzelm@12014
   124
fun the_locale thy name =
wenzelm@12014
   125
  (case get_locale thy name of
wenzelm@12014
   126
    Some loc => loc
wenzelm@12014
   127
  | None => error ("Unknown locale " ^ quote name));
wenzelm@11896
   128
wenzelm@11896
   129
wenzelm@12058
   130
(* print locales *)    (* FIXME activate local syntax *)
wenzelm@12014
   131
wenzelm@12014
   132
fun pretty_locale thy xname =
wenzelm@12014
   133
  let
wenzelm@12014
   134
    val sg = Theory.sign_of thy;
wenzelm@12014
   135
    val name = intern sg xname;
wenzelm@12063
   136
    val {imports, elements, closed = _} = the_locale thy name;
wenzelm@12014
   137
wenzelm@12014
   138
    val prt_typ = Pretty.quote o Sign.pretty_typ sg;
wenzelm@12014
   139
    val prt_term = Pretty.quote o Sign.pretty_term sg;
wenzelm@12014
   140
wenzelm@12014
   141
    fun prt_syn syn =
wenzelm@12014
   142
      let val s = (case syn of None => "(structure)" | Some mx => Syntax.string_of_mixfix mx)
wenzelm@12014
   143
      in if s = "" then [] else [Pretty.brk 4, Pretty.str s] end;
wenzelm@12058
   144
    fun prt_fix (x, Some T, syn) = Pretty.block (Pretty.str (x ^ " ::") :: Pretty.brk 1 ::
wenzelm@12058
   145
          prt_typ T :: Pretty.brk 1 :: prt_syn syn)
wenzelm@12058
   146
      | prt_fix (x, None, syn) = Pretty.block (Pretty.str x :: Pretty.brk 1 :: prt_syn syn);
wenzelm@12014
   147
wenzelm@12014
   148
    fun prt_asm ((a, _), ts) = Pretty.block
wenzelm@12014
   149
      (Pretty.breaks (Pretty.str (a ^ ":") :: map (prt_term o fst) ts));
wenzelm@12014
   150
    fun prt_asms asms = Pretty.block
wenzelm@12014
   151
      (flat (separate [Pretty.fbrk, Pretty.str "and"] (map (single o prt_asm) asms)));
wenzelm@12014
   152
wenzelm@12014
   153
    fun prt_def ((a, _), (t, _)) = Pretty.block
wenzelm@12014
   154
      [Pretty.str (a ^ ":"), Pretty.brk 1, prt_term t];
wenzelm@12014
   155
wenzelm@12014
   156
    fun prt_fact ((a, _), ths) = Pretty.block
wenzelm@12014
   157
      (Pretty.breaks (Pretty.str (a ^ ":") :: map Display.pretty_thm (flat (map fst ths))));
wenzelm@12014
   158
wenzelm@12014
   159
    fun prt_elem (Fixes fixes) = Pretty.big_list "fixes" (map prt_fix fixes)
wenzelm@12014
   160
      | prt_elem (Assumes asms) = Pretty.big_list "assumes" (map prt_asm asms)
wenzelm@12014
   161
      | prt_elem (Defines defs) = Pretty.big_list "defines" (map prt_def defs)
wenzelm@12014
   162
      | prt_elem (Notes facts) = Pretty.big_list "notes" (map prt_fact facts)
wenzelm@12014
   163
      | prt_elem (Uses _) = Pretty.str "FIXME";
wenzelm@12014
   164
wenzelm@12014
   165
    val prt_header = Pretty.block (Pretty.str ("locale " ^ cond_extern sg name ^ " =") ::
wenzelm@12063
   166
       (if null imports then [] else
wenzelm@12063
   167
       (flat (separate [Pretty.str "+", Pretty.brk 1] (map (single o Pretty.str) imports)) @
wenzelm@12014
   168
         [Pretty.str "+"])));
wenzelm@12014
   169
  in Pretty.block (Pretty.fbreaks (prt_header :: map prt_elem elements)) end;
wenzelm@12014
   170
wenzelm@12014
   171
val print_locale = Pretty.writeln oo pretty_locale;
wenzelm@11896
   172
wenzelm@11896
   173
wenzelm@12046
   174
wenzelm@12063
   175
(** internalize elements **)
wenzelm@12063
   176
wenzelm@12063
   177
(* read_elem *)
wenzelm@12046
   178
wenzelm@12063
   179
fun read_elem ctxt =
wenzelm@12063
   180
 fn Fixes fixes =>
wenzelm@12063
   181
      let val vars =
wenzelm@12063
   182
        #2 (foldl_map ProofContext.read_vars (ctxt, map (fn (x, T, _) => ([x], T)) fixes))
wenzelm@12063
   183
      in Fixes (map2 (fn (([x'], T'), (_, _, mx)) => (x', T', mx)) (vars, fixes)) end
wenzelm@12063
   184
  | Assumes asms =>
wenzelm@12063
   185
      Assumes (map #1 asms ~~ #2 (ProofContext.read_propp (ctxt, map #2 asms)))
wenzelm@12063
   186
  | Defines defs =>
wenzelm@12063
   187
      let val propps =
wenzelm@12063
   188
        #2 (ProofContext.read_propp (ctxt, map (fn (_, (t, ps)) => [(t, (ps, []))]) defs))
wenzelm@12063
   189
      in Defines (map #1 defs ~~ map (fn [(t', (ps', []))] => (t', ps')) propps) end
wenzelm@12063
   190
  | Notes facts =>
wenzelm@12063
   191
      Notes (map (apsnd (map (apfst (ProofContext.get_thms ctxt)))) facts)
wenzelm@12063
   192
  | Uses FIXME => Uses FIXME;
wenzelm@12063
   193
wenzelm@12063
   194
wenzelm@12063
   195
(* prepare attributes *)
wenzelm@12063
   196
wenzelm@12063
   197
local fun int_att attrib (x, srcs) = (x, map attrib srcs) in
wenzelm@12063
   198
wenzelm@12063
   199
fun attribute _ (Fixes fixes) = Fixes fixes
wenzelm@12063
   200
  | attribute attrib (Assumes asms) = Assumes (map (apfst (int_att attrib)) asms)
wenzelm@12063
   201
  | attribute attrib (Defines defs) = Defines (map (apfst (int_att attrib)) defs)
wenzelm@12063
   202
  | attribute attrib (Notes facts) =
wenzelm@12046
   203
      Notes (map (apfst (int_att attrib) o apsnd (map (int_att attrib))) facts)
wenzelm@12063
   204
  | attribute _ (Uses FIXME) = Uses FIXME;
wenzelm@12063
   205
wenzelm@12063
   206
end;
wenzelm@12046
   207
wenzelm@12046
   208
wenzelm@11896
   209
wenzelm@12014
   210
(** activate locales **)
wenzelm@11896
   211
wenzelm@12063
   212
(* activatation primitive *)
wenzelm@12046
   213
wenzelm@12046
   214
fun activate (ctxt, Fixes fixes) =
wenzelm@12058
   215
      ProofContext.fix_direct (map (fn (x, T, FIXME) => ([x], T)) fixes) ctxt
wenzelm@12058
   216
  | activate (ctxt, Assumes asms) =
wenzelm@12058
   217
      ctxt |> ProofContext.fix_frees (flat (map (map #1 o #2) asms))
wenzelm@12058
   218
      |> ProofContext.assume_i ProofContext.export_assume asms |> #1
wenzelm@12046
   219
  | activate (ctxt, Defines defs) = #1 (ProofContext.assume_i ProofContext.export_def
wenzelm@12058
   220
      (map (fn (a, (t, ps)) => (a, [(ProofContext.cert_def ctxt t, (ps, []))])) defs) ctxt)
wenzelm@12046
   221
  | activate (ctxt, Notes facts) = #1 (ProofContext.have_thmss facts ctxt)
wenzelm@12046
   222
  | activate (ctxt, Uses FIXME) = ctxt;
wenzelm@11896
   223
wenzelm@12063
   224
wenzelm@12063
   225
(* activate operations *)
wenzelm@11896
   226
wenzelm@12046
   227
fun activate_elements_i elems ctxt = foldl activate (ctxt, elems);
wenzelm@12063
   228
fun activate_elements elems ctxt =
wenzelm@12063
   229
  foldl ((fn (ctxt, elem) => activate (ctxt, read_elem ctxt elem))) (ctxt, elems);
wenzelm@12046
   230
wenzelm@12063
   231
fun activate_locale_elements (ctxt, name) =
wenzelm@12014
   232
  let
wenzelm@12014
   233
    val thy = ProofContext.theory_of ctxt;
wenzelm@12063
   234
    val {elements, ...} = the_locale thy name;    (*exception ERROR*)
wenzelm@12014
   235
  in
wenzelm@12063
   236
    activate_elements_i elements ctxt handle ProofContext.CONTEXT (msg, c) =>
wenzelm@12014
   237
      raise ProofContext.CONTEXT (msg ^ "\nThe error(s) above occurred in locale " ^
wenzelm@12014
   238
        quote (cond_extern (Theory.sign_of thy) name), c)
wenzelm@12014
   239
  end;
wenzelm@12014
   240
wenzelm@12046
   241
fun activate_locale_i name ctxt =
wenzelm@12063
   242
  activate_locale_elements (foldl activate_locale_elements
wenzelm@12063
   243
    (ctxt, #imports (the_locale (ProofContext.theory_of ctxt) name)), name);
wenzelm@12046
   244
wenzelm@12046
   245
fun activate_locale xname ctxt =
wenzelm@12046
   246
  activate_locale_i (intern (ProofContext.sign_of ctxt) xname) ctxt;
wenzelm@11896
   247
wenzelm@11896
   248
wenzelm@11896
   249
wenzelm@11896
   250
(** define locales **)
wenzelm@11896
   251
wenzelm@12063
   252
(* closeup dangling frees *)
wenzelm@12063
   253
wenzelm@12063
   254
fun close_frees_wrt ctxt t =
wenzelm@12063
   255
  let val frees = rev (filter_out (ProofContext.is_fixed ctxt o #1) (Drule.add_frees ([], t)))
wenzelm@12063
   256
  in curry Term.list_all_free frees end;
wenzelm@11896
   257
wenzelm@12063
   258
fun closeup ctxt (Assumes asms) = Assumes (asms |> map (fn (a, propps) =>
wenzelm@12063
   259
      (a, propps |> map (fn (t, (ps1, ps2)) =>
wenzelm@12063
   260
        let val close = close_frees_wrt ctxt t in (close t, (map close ps1, map close ps2)) end))))
wenzelm@12063
   261
  | closeup ctxt (Defines defs) = Defines (defs |> map (fn (a, (t, ps)) =>
wenzelm@12063
   262
      let
wenzelm@12063
   263
        val t' = ProofContext.cert_def ctxt t;
wenzelm@12063
   264
        val close = close_frees_wrt ctxt t';
wenzelm@12063
   265
      in (a, (close t', map close ps)) end))
wenzelm@12063
   266
  | closeup ctxt elem = elem;
wenzelm@11896
   267
wenzelm@11896
   268
wenzelm@12063
   269
(* add_locale(_i) *)
wenzelm@11896
   270
wenzelm@12063
   271
fun gen_add_locale prep_locale prep_elem bname raw_imports raw_elems thy =
wenzelm@12063
   272
  let
wenzelm@12063
   273
    val sign = Theory.sign_of thy;
wenzelm@11896
   274
    val name = Sign.full_name sign bname;
wenzelm@12063
   275
    val _ =
wenzelm@12063
   276
      if is_none (get_locale thy name) then () else
wenzelm@12063
   277
      error ("Duplicate definition of locale " ^ quote name);
wenzelm@11896
   278
wenzelm@12063
   279
    val imports = map (prep_locale sign) raw_imports;
wenzelm@12063
   280
    val imports_ctxt = foldl activate_locale_elements (ProofContext.init thy, imports);
wenzelm@12063
   281
    fun prep (ctxt, raw_elem) =
wenzelm@12063
   282
      let val elem = closeup ctxt (prep_elem ctxt raw_elem)
wenzelm@12063
   283
      in (activate (ctxt, elem), elem) end;
wenzelm@12063
   284
    val (locale_ctxt, elems) = foldl_map prep (imports_ctxt, raw_elems);
wenzelm@12063
   285
  in
wenzelm@12063
   286
    thy
wenzelm@12063
   287
    |> declare_locale name
wenzelm@12063
   288
    |> put_locale name (make_locale imports elems false)
wenzelm@12063
   289
  end;
wenzelm@12063
   290
wenzelm@12063
   291
val add_locale = gen_add_locale intern read_elem;
wenzelm@12063
   292
val add_locale_i = gen_add_locale (K I) (K I);
wenzelm@12063
   293
wenzelm@11896
   294
wenzelm@12063
   295
wenzelm@12063
   296
(** store results **)    (* FIXME test atts!? *)
wenzelm@11896
   297
wenzelm@12063
   298
fun store_thm name ((a, th), atts) thy =
wenzelm@12063
   299
  let
wenzelm@12063
   300
    val note = Notes [((a, atts), [([Thm.name_thm (a, th)], [])])];
wenzelm@12063
   301
    val {imports, elements, closed} = the_locale thy name;
wenzelm@12063
   302
  in
wenzelm@12063
   303
    if closed then error ("Cannot store results in closed locale: " ^ quote name)
wenzelm@12063
   304
    else thy |> put_locale name (make_locale imports (elements @ [note]) closed)
wenzelm@12063
   305
  end;
wenzelm@11896
   306
wenzelm@12063
   307
wenzelm@12063
   308
(* FIXME old
wenzelm@12063
   309
wenzelm@11896
   310
        val mx = Syntax.fix_mixfix raw_c raw_mx;
wenzelm@11896
   311
        val (envS', T) = prep_typ sign (envS, raw_T) handle ERROR =>
wenzelm@11896
   312
          error ("The error(s) above occured in locale constant " ^ quote c);
wenzelm@11896
   313
        val trfun = if mx = Syntax.NoSyn then None else Some (c_syn, mk_loc_tr c);
wenzelm@11896
   314
      in (envS', ((c, T), (c_syn, T, mx), trfun)) end;
wenzelm@11896
   315
wenzelm@12014
   316
    val (envS0, loc_fixes_syn) = foldl_map prep_const (envSb, raw_fixes);
wenzelm@12014
   317
    val loc_fixes = map #1 loc_fixes_syn;
wenzelm@12014
   318
    val loc_fixes = old_loc_fixes @ loc_fixes;
wenzelm@12014
   319
    val loc_syn = map #2 loc_fixes_syn;
wenzelm@12014
   320
    val nosyn = old_nosyn @ (map (#1 o #1) (filter (fn x => (#3(#2 x)) = NoSyn) loc_fixes_syn));
wenzelm@12014
   321
    val loc_trfuns = mapfilter #3 loc_fixes_syn;
wenzelm@11896
   322
wenzelm@11896
   323
    val syntax_thy =
wenzelm@11896
   324
      thy
wenzelm@11896
   325
      |> Theory.add_modesyntax_i ("", true) loc_syn
wenzelm@11896
   326
      |> Theory.add_trfuns ([], loc_trfuns, [], []);
wenzelm@11896
   327
wenzelm@12014
   328
    (* check if definientes are locale constants
wenzelm@11896
   329
       (in the same locale, so no redefining!) *)
wenzelm@11896
   330
    val err_def_head =
wenzelm@12014
   331
      let fun peal_appl t =
wenzelm@12014
   332
            case t of
wenzelm@11896
   333
                 t1 $ t2 => peal_appl t1
wenzelm@11896
   334
               | Free(t) => t
wenzelm@11896
   335
               | _ => locale_error ("Bad form of LHS in locale definition");
wenzelm@12014
   336
          fun lhs (_, Const ("==" , _) $  d1 $ d2) = peal_appl d1
wenzelm@12014
   337
            | lhs _ = locale_error ("Definitions must use the == relation");
wenzelm@11896
   338
          val defs = map lhs loc_defs;
wenzelm@12014
   339
          val check = defs subset loc_fixes
wenzelm@12014
   340
      in if check then []
wenzelm@11896
   341
         else ["defined item not declared fixed in locale " ^ quote name]
wenzelm@12014
   342
      end;
wenzelm@11896
   343
wenzelm@11896
   344
    (* check that variables on rhs of definitions are either fixed or on lhs *)
wenzelm@12014
   345
    val err_var_rhs =
wenzelm@12014
   346
      let fun compare_var_sides (t, (_, Const ("==", _) $ d1 $ d2)) =
wenzelm@12014
   347
                let val varl1 = difflist d1 all_loc_fixes;
wenzelm@12014
   348
                    val varl2 = difflist d2 all_loc_fixes
wenzelm@12014
   349
                in t andalso (varl2 subset varl1)
wenzelm@12014
   350
                end
wenzelm@12014
   351
            | compare_var_sides (_,_) =
wenzelm@12014
   352
                locale_error ("Definitions must use the == relation")
wenzelm@11896
   353
          val check = foldl compare_var_sides (true, loc_defs)
wenzelm@11896
   354
      in if check then []
wenzelm@11896
   355
         else ["nonfixed variable on right hand side of a locale definition in locale " ^ quote name]
wenzelm@11896
   356
      end;
wenzelm@12014
   357
*)
wenzelm@11896
   358
wenzelm@11896
   359
wenzelm@11896
   360
(** locale theory setup **)
wenzelm@12063
   361
wenzelm@11896
   362
val setup =
wenzelm@11896
   363
 [LocalesData.init];
wenzelm@11896
   364
wenzelm@11896
   365
end;
wenzelm@11896
   366
wenzelm@11896
   367
structure BasicLocale: BASIC_LOCALE = Locale;
wenzelm@11896
   368
open BasicLocale;