src/Pure/pure_thy.ML
author wenzelm
Tue Aug 05 13:31:35 2008 +0200 (2008-08-05)
changeset 27739 cd1df29db620
parent 27728 9a9e54042800
child 27865 27a8ad9612a3
permissions -rw-r--r--
get_fact: report position;
wenzelm@3987
     1
(*  Title:      Pure/pure_thy.ML
wenzelm@3987
     2
    ID:         $Id$
wenzelm@3987
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@3987
     4
wenzelm@26430
     5
Theorem storage.  Pure theory syntax and logical content.
wenzelm@3987
     6
*)
wenzelm@3987
     7
wenzelm@3987
     8
signature PURE_THY =
wenzelm@3987
     9
sig
wenzelm@23657
    10
  val tag_rule: Markup.property -> thm -> thm
wenzelm@18801
    11
  val untag_rule: string -> thm -> thm
wenzelm@23657
    12
  val tag: Markup.property -> attribute
wenzelm@18801
    13
  val untag: string -> attribute
wenzelm@21964
    14
  val has_name_hint: thm -> bool
wenzelm@21646
    15
  val get_name_hint: thm -> string
wenzelm@21646
    16
  val put_name_hint: string -> thm -> thm
wenzelm@25981
    17
  val get_group: thm -> string option
wenzelm@25981
    18
  val put_group: string -> thm -> thm
wenzelm@25981
    19
  val group: string -> attribute
wenzelm@22251
    20
  val has_kind: thm -> bool
wenzelm@18801
    21
  val get_kind: thm -> string
wenzelm@18801
    22
  val kind_rule: string -> thm -> thm
wenzelm@18801
    23
  val kind: string -> attribute
wenzelm@18801
    24
  val kind_internal: attribute
wenzelm@23657
    25
  val has_internal: Markup.property list -> bool
wenzelm@18801
    26
  val is_internal: thm -> bool
wenzelm@27198
    27
  val facts_of: theory -> Facts.T
wenzelm@26666
    28
  val intern_fact: theory -> xstring -> string
wenzelm@26693
    29
  val defined_fact: theory -> string -> bool
wenzelm@27198
    30
  val hide_fact: bool -> string -> theory -> theory
wenzelm@26683
    31
  val get_fact: Context.generic -> theory -> Facts.ref -> thm list
wenzelm@26344
    32
  val get_thms: theory -> xstring -> thm list
wenzelm@26344
    33
  val get_thm: theory -> xstring -> thm
wenzelm@16336
    34
  val all_thms_of: theory -> (string * thm) list
wenzelm@21580
    35
  val map_facts: ('a -> 'b) -> ('c * ('a list * 'd) list) list -> ('c * ('b list * 'd) list) list
wenzelm@21567
    36
  val burrow_fact: ('a list -> 'b list) -> ('a list * 'c) list -> ('b list * 'c) list
wenzelm@21580
    37
  val burrow_facts: ('a list -> 'b list) ->
wenzelm@21580
    38
    ('c * ('a list * 'd) list) list -> ('c * ('b list * 'd) list) list
wenzelm@21580
    39
  val name_multi: string -> 'a list -> (string * 'a) list
wenzelm@21646
    40
  val name_thm: bool -> bool -> string -> thm -> thm
wenzelm@21646
    41
  val name_thms: bool -> bool -> string -> thm list -> thm list
wenzelm@21646
    42
  val name_thmss: bool -> string -> (thm list * 'a) list -> (thm list * 'a) list
wenzelm@26488
    43
  val store_thms: bstring * thm list -> theory -> thm list * theory
wenzelm@26488
    44
  val store_thm: bstring * thm -> theory -> thm * theory
wenzelm@26488
    45
  val store_thm_open: bstring * thm -> theory -> thm * theory
haftmann@27691
    46
  val add_thms: ((bstring * thm) * attribute list) list -> theory -> thm list * theory
haftmann@27683
    47
  val add_thm: (bstring * thm) * attribute list -> theory -> thm * theory
wenzelm@24965
    48
  val add_thmss: ((bstring * thm list) * attribute list) list -> theory -> thm list list * theory
wenzelm@26488
    49
  val add_thms_dynamic: bstring * (Context.generic -> thm list) -> theory -> theory
wenzelm@18801
    50
  val note_thmss: string -> ((bstring * attribute list) *
wenzelm@18801
    51
    (thm list * attribute list) list) list -> theory -> (bstring * thm list) list * theory
wenzelm@25981
    52
  val note_thmss_grouped: string -> string -> ((bstring * attribute list) *
wenzelm@25981
    53
    (thm list * attribute list) list) list -> theory -> (bstring * thm list) list * theory
haftmann@27691
    54
  val add_axioms: ((bstring * term) * attribute list) list -> theory -> thm list * theory
haftmann@27691
    55
  val add_axioms_cmd: ((bstring * string) * attribute list) list -> theory -> thm list * theory
haftmann@27691
    56
  val add_defs: bool -> ((bstring * term) * attribute list) list ->
haftmann@18377
    57
    theory -> thm list * theory
haftmann@27691
    58
  val add_defs_unchecked: bool -> ((bstring * term) * attribute list) list ->
haftmann@18377
    59
    theory -> thm list * theory
haftmann@27691
    60
  val add_defs_unchecked_cmd: bool -> ((bstring * string) * attribute list) list ->
wenzelm@19629
    61
    theory -> thm list * theory
haftmann@27691
    62
  val add_defs_cmd: bool -> ((bstring * string) * attribute list) list ->
wenzelm@19629
    63
    theory -> thm list * theory
wenzelm@26959
    64
  val old_appl_syntax: theory -> bool
wenzelm@26959
    65
  val old_appl_syntax_setup: theory -> theory
wenzelm@3987
    66
end;
wenzelm@3987
    67
wenzelm@3987
    68
structure PureThy: PURE_THY =
wenzelm@3987
    69
struct
wenzelm@3987
    70
wenzelm@3987
    71
wenzelm@18801
    72
(*** theorem tags ***)
wenzelm@18801
    73
wenzelm@18801
    74
(* add / delete tags *)
wenzelm@18801
    75
wenzelm@21646
    76
fun tag_rule tg = Thm.map_tags (insert (op =) tg);
wenzelm@21646
    77
fun untag_rule s = Thm.map_tags (filter_out (fn (s', _) => s = s'));
wenzelm@18801
    78
wenzelm@18801
    79
fun tag tg x = Thm.rule_attribute (K (tag_rule tg)) x;
wenzelm@18801
    80
fun untag s x = Thm.rule_attribute (K (untag_rule s)) x;
wenzelm@18801
    81
wenzelm@18801
    82
wenzelm@21646
    83
(* unofficial theorem names *)
wenzelm@21646
    84
wenzelm@23657
    85
fun the_name_hint thm = the (AList.lookup (op =) (Thm.get_tags thm) Markup.nameN);
wenzelm@22251
    86
wenzelm@22251
    87
val has_name_hint = can the_name_hint;
wenzelm@22251
    88
val get_name_hint = the_default "??.unknown" o try the_name_hint;
wenzelm@21646
    89
wenzelm@23657
    90
fun put_name_hint name = untag_rule Markup.nameN #> tag_rule (Markup.nameN, name);
wenzelm@21964
    91
wenzelm@21646
    92
wenzelm@25981
    93
(* theorem groups *)
wenzelm@25981
    94
wenzelm@25981
    95
fun get_group thm = AList.lookup (op =) (Thm.get_tags thm) Markup.groupN;
wenzelm@25981
    96
wenzelm@25981
    97
fun put_group name =
wenzelm@25981
    98
  if name = "" then I else Thm.map_tags (AList.update (op =) (Markup.groupN, name));
wenzelm@25981
    99
wenzelm@25981
   100
fun group name = Thm.rule_attribute (K (put_group name));
wenzelm@25981
   101
wenzelm@25981
   102
wenzelm@18801
   103
(* theorem kinds *)
wenzelm@18801
   104
wenzelm@23657
   105
fun the_kind thm = the (AList.lookup (op =) (Thm.get_tags thm) Markup.kindN);
wenzelm@22251
   106
wenzelm@22251
   107
val has_kind = can the_kind;
wenzelm@25981
   108
val get_kind = the_default "" o try the_kind;
wenzelm@18801
   109
wenzelm@23657
   110
fun kind_rule k = tag_rule (Markup.kindN, k) o untag_rule Markup.kindN;
wenzelm@18801
   111
fun kind k x = if k = "" then x else Thm.rule_attribute (K (kind_rule k)) x;
wenzelm@22363
   112
fun kind_internal x = kind Thm.internalK x;
wenzelm@23657
   113
fun has_internal tags = exists (fn tg => tg = (Markup.kindN, Thm.internalK)) tags;
wenzelm@21646
   114
val is_internal = has_internal o Thm.get_tags;
wenzelm@18801
   115
wenzelm@18801
   116
wenzelm@18801
   117
wenzelm@27198
   118
(*** stored facts ***)
wenzelm@3987
   119
wenzelm@27198
   120
(** theory data **)
wenzelm@26282
   121
wenzelm@27198
   122
structure FactsData = TheoryDataFun
wenzelm@24713
   123
(
wenzelm@27198
   124
  type T = Facts.T;
wenzelm@27198
   125
  val empty = Facts.empty;
wenzelm@26488
   126
  val copy = I;
wenzelm@27198
   127
  val extend = I;
wenzelm@27198
   128
  fun merge _ = Facts.merge;
wenzelm@24713
   129
);
wenzelm@3987
   130
wenzelm@27198
   131
val facts_of = FactsData.get;
wenzelm@26666
   132
wenzelm@26666
   133
val intern_fact = Facts.intern o facts_of;
wenzelm@26693
   134
val defined_fact = Facts.defined o facts_of;
wenzelm@16023
   135
wenzelm@27198
   136
fun hide_fact fully name = FactsData.map (Facts.hide fully name);
wenzelm@27198
   137
wenzelm@6367
   138
wenzelm@3987
   139
wenzelm@4022
   140
(** retrieve theorems **)
wenzelm@3987
   141
wenzelm@27198
   142
fun get_fact context thy xthmref =
wenzelm@26683
   143
  let
wenzelm@26683
   144
    val xname = Facts.name_of_ref xthmref;
wenzelm@26683
   145
    val pos = Facts.pos_of_ref xthmref;
wenzelm@27198
   146
wenzelm@27198
   147
    val name = intern_fact thy xname;
wenzelm@27198
   148
    val res = Facts.lookup context (facts_of thy) name;
wenzelm@27198
   149
    val _ = Theory.check_thy thy;
wenzelm@26683
   150
  in
wenzelm@27198
   151
    (case res of
wenzelm@27198
   152
      NONE => error ("Unknown fact " ^ quote name ^ Position.str_of pos)
wenzelm@27739
   153
    | SOME (static, ths) =>
wenzelm@27739
   154
        (Position.report ((if static then Markup.fact else Markup.dynamic_fact) name) pos;
wenzelm@27739
   155
         Facts.select xthmref (map (Thm.transfer thy) ths)))
wenzelm@26683
   156
  end;
wenzelm@26344
   157
wenzelm@26683
   158
fun get_thms thy = get_fact (Context.Theory thy) thy o Facts.named;
wenzelm@26344
   159
fun get_thm thy name = Facts.the_single name (get_thms thy name);
wenzelm@4783
   160
wenzelm@27198
   161
fun all_thms_of thy =
wenzelm@27198
   162
  Facts.fold_static (fn (_, ths) => append (map (`(get_name_hint)) ths)) (facts_of thy) [];
wenzelm@16336
   163
wenzelm@4022
   164
wenzelm@4022
   165
wenzelm@26488
   166
(** store theorems **)
wenzelm@3987
   167
wenzelm@21580
   168
(* fact specifications *)
wenzelm@21580
   169
wenzelm@21580
   170
fun map_facts f = map (apsnd (map (apfst (map f))));
wenzelm@21580
   171
fun burrow_fact f = split_list #>> burrow f #> op ~~;
wenzelm@21580
   172
fun burrow_facts f = split_list ##> burrow (burrow_fact f) #> op ~~;
wenzelm@21580
   173
wenzelm@21580
   174
wenzelm@4853
   175
(* naming *)
wenzelm@4853
   176
wenzelm@18801
   177
fun name_multi name [x] = [(name, x)]
wenzelm@26457
   178
  | name_multi "" xs = map (pair "") xs
wenzelm@26457
   179
  | name_multi name xs = map_index (fn (i, x) => (name ^ "_" ^ string_of_int (i + 1), x)) xs;
berghofe@12235
   180
wenzelm@21646
   181
fun name_thm pre official name thm = thm
wenzelm@21646
   182
  |> (if Thm.get_name thm <> "" andalso pre orelse not official then I else Thm.put_name name)
wenzelm@26050
   183
  |> (if has_name_hint thm andalso pre orelse name = "" then I else put_name_hint name)
wenzelm@26050
   184
  |> Thm.map_tags (Position.default_properties (Position.thread_data ()));
berghofe@12872
   185
wenzelm@21646
   186
fun name_thms pre official name xs =
wenzelm@21646
   187
  map (uncurry (name_thm pre official)) (name_multi name xs);
berghofe@12235
   188
wenzelm@21646
   189
fun name_thmss official name fact =
wenzelm@21646
   190
  burrow_fact (name_thms true official name) fact;
wenzelm@4853
   191
wenzelm@4853
   192
berghofe@11998
   193
(* enter_thms *)
wenzelm@4853
   194
haftmann@18418
   195
fun enter_thms _ _ app_att ("", thms) thy = app_att (thy, thms) |> swap
wenzelm@26488
   196
  | enter_thms pre_name post_name app_att (bname, thms) thy =
wenzelm@7470
   197
      let
wenzelm@26488
   198
        val naming = Sign.naming_of thy;
wenzelm@26488
   199
        val name = NameSpace.full naming bname;
wenzelm@16441
   200
        val (thy', thms') = apsnd (post_name name) (app_att (thy, pre_name name thms));
wenzelm@26488
   201
        val thms'' = map (Thm.transfer thy') thms';
wenzelm@27198
   202
        val thy'' = thy' |> FactsData.map (Facts.add_global naming (name, thms''));
wenzelm@26488
   203
      in (thms'', thy'') end;
wenzelm@26488
   204
wenzelm@26488
   205
wenzelm@26488
   206
(* store_thm(s) *)
wenzelm@26488
   207
wenzelm@26488
   208
val store_thms = enter_thms (name_thms true true) (name_thms false true) I;
wenzelm@26488
   209
fun store_thm (name, th) = store_thms (name, [th]) #>> the_single;
wenzelm@26488
   210
wenzelm@26488
   211
fun store_thm_open (name, th) =
wenzelm@26488
   212
  enter_thms (name_thms true false) (name_thms false false) I (name, [th]) #>> the_single;
wenzelm@3987
   213
wenzelm@16023
   214
wenzelm@6091
   215
(* add_thms(s) *)
wenzelm@4853
   216
wenzelm@16441
   217
fun add_thms_atts pre_name ((bname, thms), atts) =
wenzelm@21646
   218
  enter_thms pre_name (name_thms false true)
wenzelm@21646
   219
    (foldl_map (Thm.theory_attributes atts)) (bname, thms);
wenzelm@4853
   220
haftmann@18377
   221
fun gen_add_thmss pre_name =
haftmann@18377
   222
  fold_map (add_thms_atts pre_name);
wenzelm@5907
   223
berghofe@12235
   224
fun gen_add_thms pre_name args =
haftmann@18377
   225
  apfst (map hd) o gen_add_thmss pre_name (map (apfst (apsnd single)) args);
berghofe@12235
   226
wenzelm@21646
   227
val add_thmss = gen_add_thmss (name_thms true true);
wenzelm@21646
   228
val add_thms = gen_add_thms (name_thms true true);
haftmann@27683
   229
val add_thm = yield_singleton add_thms;
wenzelm@5907
   230
wenzelm@5907
   231
wenzelm@26488
   232
(* add_thms_dynamic *)
wenzelm@26488
   233
wenzelm@26488
   234
fun add_thms_dynamic (bname, f) thy =
wenzelm@27198
   235
  let val name = Sign.full_name thy bname
wenzelm@27198
   236
  in thy |> FactsData.map (Facts.add_dynamic (Sign.naming_of thy) (name, f)) end;
wenzelm@26488
   237
wenzelm@26488
   238
wenzelm@27728
   239
(* note_thmss *)
wenzelm@5907
   240
wenzelm@9192
   241
local
wenzelm@12711
   242
wenzelm@27728
   243
fun gen_note_thmss tag = fold_map (fn ((bname, more_atts), ths_atts) => fn thy =>
wenzelm@12711
   244
  let
wenzelm@18728
   245
    fun app (x, (ths, atts)) = foldl_map (Thm.theory_attributes atts) (x, ths);
haftmann@18418
   246
    val (thms, thy') = thy |> enter_thms
wenzelm@21646
   247
      (name_thmss true) (name_thms false true) (apsnd flat o foldl_map app)
wenzelm@27728
   248
      (bname, map (fn (ths, atts) => (ths, surround tag (atts @ more_atts))) ths_atts);
wenzelm@18801
   249
  in ((bname, thms), thy') end);
wenzelm@12711
   250
wenzelm@9192
   251
in
wenzelm@12711
   252
wenzelm@27728
   253
fun note_thmss k = gen_note_thmss (kind k);
wenzelm@27728
   254
fun note_thmss_grouped k g = gen_note_thmss (kind k #> group g);
wenzelm@12711
   255
wenzelm@21438
   256
end;
wenzelm@21438
   257
wenzelm@5280
   258
wenzelm@4022
   259
(* store axioms as theorems *)
wenzelm@4022
   260
wenzelm@4853
   261
local
wenzelm@17418
   262
  fun get_ax thy (name, _) = Thm.get_axiom_i thy (Sign.full_name thy name);
wenzelm@26655
   263
  fun get_axs thy named_axs = map (Thm.forall_elim_vars 0 o get_ax thy) named_axs;
wenzelm@26553
   264
  fun add_axm add = fold_map (fn ((name, ax), atts) => fn thy =>
wenzelm@4853
   265
    let
berghofe@11998
   266
      val named_ax = [(name, ax)];
wenzelm@7753
   267
      val thy' = add named_ax thy;
wenzelm@7753
   268
      val thm = hd (get_axs thy' named_ax);
wenzelm@26553
   269
    in apfst hd (gen_add_thms (K I) [((name, thm), atts)] thy') end);
wenzelm@4853
   270
in
haftmann@27691
   271
  val add_defs               = add_axm o Theory.add_defs_i false;
haftmann@27691
   272
  val add_defs_unchecked     = add_axm o Theory.add_defs_i true;
haftmann@27691
   273
  val add_axioms             = add_axm Theory.add_axioms_i;
haftmann@27691
   274
  val add_defs_cmd           = add_axm o Theory.add_defs false;
haftmann@27691
   275
  val add_defs_unchecked_cmd = add_axm o Theory.add_defs true;
haftmann@27691
   276
  val add_axioms_cmd         = add_axm Theory.add_axioms;
wenzelm@4853
   277
end;
wenzelm@4022
   278
wenzelm@4022
   279
wenzelm@3987
   280
wenzelm@26430
   281
(*** Pure theory syntax and logical content ***)
wenzelm@3987
   282
wenzelm@24243
   283
val typ = SimpleSyntax.read_typ;
wenzelm@24243
   284
val term = SimpleSyntax.read_term;
wenzelm@24243
   285
val prop = SimpleSyntax.read_prop;
wenzelm@24243
   286
wenzelm@26959
   287
wenzelm@26959
   288
(* application syntax variants *)
wenzelm@26959
   289
wenzelm@26959
   290
val appl_syntax =
wenzelm@26959
   291
 [("_appl", typ "('b => 'a) => args => logic", Mixfix ("(1_/(1'(_')))", [1000, 0], 1000)),
wenzelm@26959
   292
  ("_appl", typ "('b => 'a) => args => aprop", Mixfix ("(1_/(1'(_')))", [1000, 0], 1000))];
wenzelm@26959
   293
wenzelm@26959
   294
val applC_syntax =
wenzelm@26959
   295
 [("",       typ "'a => cargs",                  Delimfix "_"),
wenzelm@26959
   296
  ("_cargs", typ "'a => cargs => cargs",         Mixfix ("_/ _", [1000, 1000], 1000)),
wenzelm@26959
   297
  ("_applC", typ "('b => 'a) => cargs => logic", Mixfix ("(1_/ _)", [1000, 1000], 999)),
wenzelm@26959
   298
  ("_applC", typ "('b => 'a) => cargs => aprop", Mixfix ("(1_/ _)", [1000, 1000], 999))];
wenzelm@26959
   299
wenzelm@26959
   300
structure OldApplSyntax = TheoryDataFun
wenzelm@26959
   301
(
wenzelm@26959
   302
  type T = bool;
wenzelm@26959
   303
  val empty = false;
wenzelm@26959
   304
  val copy = I;
wenzelm@26959
   305
  val extend = I;
wenzelm@26959
   306
  fun merge _ (b1, b2) : T =
wenzelm@26959
   307
    if b1 = b2 then b1
wenzelm@26959
   308
    else error "Cannot merge theories with different application syntax";
wenzelm@26959
   309
);
wenzelm@26959
   310
wenzelm@26959
   311
val old_appl_syntax = OldApplSyntax.get;
wenzelm@26959
   312
wenzelm@26959
   313
val old_appl_syntax_setup =
wenzelm@26959
   314
  OldApplSyntax.put true #>
wenzelm@26959
   315
  Sign.del_modesyntax_i Syntax.mode_default applC_syntax #>
wenzelm@26959
   316
  Sign.add_syntax_i appl_syntax;
wenzelm@26959
   317
wenzelm@26959
   318
wenzelm@26959
   319
(* main content *)
wenzelm@26959
   320
wenzelm@26463
   321
val _ = Context.>> (Context.map_theory
wenzelm@26959
   322
  (OldApplSyntax.init #>
wenzelm@26959
   323
   Sign.add_types
wenzelm@4922
   324
   [("fun", 2, NoSyn),
wenzelm@4922
   325
    ("prop", 0, NoSyn),
wenzelm@4922
   326
    ("itself", 1, NoSyn),
wenzelm@4922
   327
    ("dummy", 0, NoSyn)]
wenzelm@26430
   328
  #> Sign.add_nonterminals Syntax.basic_nonterms
wenzelm@26430
   329
  #> Sign.add_syntax_i
wenzelm@26436
   330
   [("_lambda",     typ "pttrns => 'a => logic",       Mixfix ("(3%_./ _)", [0, 3], 3)),
wenzelm@26436
   331
    ("_abs",        typ "'a",                          NoSyn),
wenzelm@26436
   332
    ("",            typ "'a => args",                  Delimfix "_"),
wenzelm@26436
   333
    ("_args",       typ "'a => args => args",          Delimfix "_,/ _"),
wenzelm@26436
   334
    ("",            typ "id => idt",                   Delimfix "_"),
wenzelm@26436
   335
    ("_idtdummy",   typ "idt",                         Delimfix "'_"),
wenzelm@26436
   336
    ("_idtyp",      typ "id => type => idt",           Mixfix ("_::_", [], 0)),
wenzelm@26436
   337
    ("_idtypdummy", typ "type => idt",                 Mixfix ("'_()::_", [], 0)),
wenzelm@26436
   338
    ("",            typ "idt => idt",                  Delimfix "'(_')"),
wenzelm@26436
   339
    ("",            typ "idt => idts",                 Delimfix "_"),
wenzelm@26436
   340
    ("_idts",       typ "idt => idts => idts",         Mixfix ("_/ _", [1, 0], 0)),
wenzelm@26436
   341
    ("",            typ "idt => pttrn",                Delimfix "_"),
wenzelm@26436
   342
    ("",            typ "pttrn => pttrns",             Delimfix "_"),
wenzelm@26436
   343
    ("_pttrns",     typ "pttrn => pttrns => pttrns",   Mixfix ("_/ _", [1, 0], 0)),
wenzelm@26436
   344
    ("",            typ "id => aprop",                 Delimfix "_"),
wenzelm@26436
   345
    ("",            typ "longid => aprop",             Delimfix "_"),
wenzelm@26436
   346
    ("",            typ "var => aprop",                Delimfix "_"),
wenzelm@26436
   347
    ("_DDDOT",      typ "aprop",                       Delimfix "..."),
wenzelm@26436
   348
    ("_aprop",      typ "aprop => prop",               Delimfix "PROP _"),
wenzelm@26436
   349
    ("_asm",        typ "prop => asms",                Delimfix "_"),
wenzelm@26436
   350
    ("_asms",       typ "prop => asms => asms",        Delimfix "_;/ _"),
wenzelm@26436
   351
    ("_bigimpl",    typ "asms => prop => prop",        Mixfix ("((3[| _ |])/ ==> _)", [0, 1], 1)),
wenzelm@26436
   352
    ("_ofclass",    typ "type => logic => prop",       Delimfix "(1OFCLASS/(1'(_,/ _')))"),
wenzelm@26436
   353
    ("_mk_ofclass", typ "dummy",                       NoSyn),
wenzelm@26436
   354
    ("_TYPE",       typ "type => logic",               Delimfix "(1TYPE/(1'(_')))"),
wenzelm@26436
   355
    ("",            typ "id => logic",                 Delimfix "_"),
wenzelm@26436
   356
    ("",            typ "longid => logic",             Delimfix "_"),
wenzelm@26436
   357
    ("",            typ "var => logic",                Delimfix "_"),
wenzelm@26436
   358
    ("_DDDOT",      typ "logic",                       Delimfix "..."),
wenzelm@26436
   359
    ("_constify",   typ "num => num_const",            Delimfix "_"),
wenzelm@26436
   360
    ("_indexnum",   typ "num_const => index",          Delimfix "\\<^sub>_"),
wenzelm@26436
   361
    ("_index",      typ "logic => index",              Delimfix "(00\\<^bsub>_\\<^esub>)"),
wenzelm@26436
   362
    ("_indexdefault", typ "index",                     Delimfix ""),
wenzelm@26436
   363
    ("_indexvar",   typ "index",                       Delimfix "'\\<index>"),
wenzelm@26436
   364
    ("_struct",     typ "index => logic",              Mixfix ("\\<struct>_", [1000], 1000)),
wenzelm@26436
   365
    ("==>",         typ "prop => prop => prop",        Delimfix "op ==>"),
wenzelm@26959
   366
    (Term.dummy_patternN, typ "aprop",                 Delimfix "'_")]
wenzelm@26959
   367
  #> Sign.add_syntax_i applC_syntax
wenzelm@26430
   368
  #> Sign.add_modesyntax_i (Symbol.xsymbolsN, true)
wenzelm@24243
   369
   [("fun",      typ "type => type => type",   Mixfix ("(_/ \\<Rightarrow> _)", [1, 0], 0)),
wenzelm@24243
   370
    ("_bracket", typ "types => type => type",  Mixfix ("([_]/ \\<Rightarrow> _)", [0, 0], 0)),
wenzelm@24243
   371
    ("_ofsort",  typ "tid => sort => type",    Mixfix ("_\\<Colon>_", [1000, 0], 1000)),
wenzelm@24243
   372
    ("_constrain", typ "'a => type => 'a",     Mixfix ("_\\<Colon>_", [4, 0], 3)),
wenzelm@24243
   373
    ("_idtyp",    typ "id => type => idt",     Mixfix ("_\\<Colon>_", [], 0)),
wenzelm@24243
   374
    ("_idtypdummy", typ "type => idt",         Mixfix ("'_()\\<Colon>_", [], 0)),
wenzelm@24243
   375
    ("_type_constraint_", typ "'a",            NoSyn),
wenzelm@24243
   376
    ("_lambda",  typ "pttrns => 'a => logic",  Mixfix ("(3\\<lambda>_./ _)", [0, 3], 3)),
wenzelm@24243
   377
    ("==",       typ "'a => 'a => prop",       InfixrName ("\\<equiv>", 2)),
wenzelm@24243
   378
    ("all_binder", typ "idts => prop => prop", Mixfix ("(3\\<And>_./ _)", [0, 0], 0)),
wenzelm@24243
   379
    ("==>",      typ "prop => prop => prop",   InfixrName ("\\<Longrightarrow>", 1)),
wenzelm@24243
   380
    ("_DDDOT",   typ "aprop",                  Delimfix "\\<dots>"),
wenzelm@24243
   381
    ("_bigimpl", typ "asms => prop => prop",   Mixfix ("((1\\<lbrakk>_\\<rbrakk>)/ \\<Longrightarrow> _)", [0, 1], 1)),
wenzelm@24243
   382
    ("_DDDOT",   typ "logic",                  Delimfix "\\<dots>")]
wenzelm@26430
   383
  #> Sign.add_modesyntax_i ("", false)
wenzelm@24243
   384
   [("prop", typ "prop => prop", Mixfix ("_", [0], 0)),
wenzelm@26430
   385
    ("Pure.term", typ "'a => prop", Delimfix "TERM _"),
wenzelm@26430
   386
    ("Pure.conjunction", typ "prop => prop => prop", InfixrName ("&&", 2))]
wenzelm@26430
   387
  #> Sign.add_modesyntax_i ("HTML", false)
wenzelm@24243
   388
   [("_lambda", typ "pttrns => 'a => logic", Mixfix ("(3\\<lambda>_./ _)", [0, 3], 3))]
wenzelm@26430
   389
  #> Sign.add_consts_i
wenzelm@24243
   390
   [("==", typ "'a => 'a => prop", InfixrName ("==", 2)),
wenzelm@24243
   391
    ("==>", typ "prop => prop => prop", Mixfix ("(_/ ==> _)", [2, 1], 1)),
wenzelm@24243
   392
    ("all", typ "('a => prop) => prop", Binder ("!!", 0, 0)),
wenzelm@24243
   393
    ("prop", typ "prop => prop", NoSyn),
wenzelm@24243
   394
    ("TYPE", typ "'a itself", NoSyn),
wenzelm@24243
   395
    (Term.dummy_patternN, typ "'a", Delimfix "'_")]
wenzelm@26430
   396
  #> Theory.add_deps "==" ("==", typ "'a => 'a => prop") []
wenzelm@26430
   397
  #> Theory.add_deps "==>" ("==>", typ "prop => prop => prop") []
wenzelm@26430
   398
  #> Theory.add_deps "all" ("all", typ "('a => prop) => prop") []
wenzelm@26430
   399
  #> Theory.add_deps "TYPE" ("TYPE", typ "'a itself") []
wenzelm@26430
   400
  #> Theory.add_deps Term.dummy_patternN (Term.dummy_patternN, typ "'a") []
wenzelm@26430
   401
  #> Sign.add_trfuns Syntax.pure_trfuns
wenzelm@26430
   402
  #> Sign.add_trfunsT Syntax.pure_trfunsT
wenzelm@26430
   403
  #> Sign.local_path
wenzelm@26430
   404
  #> Sign.add_consts_i
wenzelm@24243
   405
   [("term", typ "'a => prop", NoSyn),
wenzelm@24243
   406
    ("conjunction", typ "prop => prop => prop", NoSyn)]
haftmann@27691
   407
  #> (add_defs false o map Thm.no_attributes)
wenzelm@24243
   408
   [("prop_def", prop "(CONST prop :: prop => prop) (A::prop) == A::prop"),
wenzelm@26430
   409
    ("term_def", prop "(CONST Pure.term :: 'a => prop) (x::'a) == (!!A::prop. A ==> A)"),
wenzelm@26430
   410
    ("conjunction_def", prop "(A && B) == (!!C::prop. (A ==> B ==> C) ==> C)")] #> snd
wenzelm@26666
   411
  #> Sign.hide_const false "Pure.conjunction"
wenzelm@26666
   412
  #> Sign.hide_const false "Pure.term"
wenzelm@26430
   413
  #> add_thmss [(("nothing", []), [])] #> snd
wenzelm@26463
   414
  #> Theory.add_axioms_i Proofterm.equality_axms));
wenzelm@3987
   415
wenzelm@3987
   416
end;
wenzelm@3987
   417