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