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