src/Pure/Isar/isar_thy.ML
author wenzelm
Mon, 09 Nov 1998 15:34:41 +0100
changeset 5831 996361157cfb
parent 5830 95b619c7289b
child 5882 c8096461f5c8
permissions -rw-r--r--
Non-logical toplevel commands.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5830
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/isar_thy.ML
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     4
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     5
Derived theory operations.
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     6
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     7
TODO:
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     8
  - add_defs: handle empty name (pure_thy.ML (!?));
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
     9
  - add_constdefs (atomic!);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    10
  - have_theorems, have_lemmas;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    11
  - load theory;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    12
  - 'methods' section (proof macros, ML method defs) (!?);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    13
  - now_block: ProofHistory open / close (!?);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    14
  - from_facts: attribs, args (!?) (beware of termination!!);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    15
*)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    16
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    17
signature ISAR_THY =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    18
sig
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    19
  val add_axioms: ((bstring * string) * Args.src list) list -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    20
  val add_defs: ((bstring * string) * Args.src list) list -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    21
  val fix: (string * string option) list -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    22
  val match_bind: (string * string) list -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    23
  val theorem: string -> Args.src list -> string -> theory -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    24
  val lemma: string -> Args.src list -> string -> theory -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    25
  val assume: string -> Args.src list -> string list -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    26
  val show: string -> Args.src list -> string -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    27
  val have: string -> Args.src list -> string -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    28
  val chain: ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    29
  val from_facts: string list -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    30
  val begin_block: ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    31
  val next_block: ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    32
  val end_block: ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    33
  val qed_with: bstring option * Args.src list option -> ProofHistory.T -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    34
  val qed: ProofHistory.T -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    35
  val kill_proof: ProofHistory.T -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    36
  val tac: Method.text -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    37
  val etac: Method.text -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    38
  val proof: Method.text option -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    39
  val terminal_proof: Method.text -> ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    40
  val trivial_proof: ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    41
  val default_proof: ProofHistory.T -> ProofHistory.T
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    42
  val use_mltext: string -> theory option -> theory option
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    43
  val use_mltext_theory: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    44
  val use_setup: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    45
  val parse_ast_translation: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    46
  val parse_translation: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    47
  val print_translation: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    48
  val typed_print_translation: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    49
  val print_ast_translation: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    50
  val token_translation: string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    51
  val add_oracle: bstring * string -> theory -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    52
  val the_theory: string -> unit -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    53
  val begin_theory: string * string list -> unit -> theory
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    54
  val end_theory: theory -> unit
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    55
end;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    56
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    57
structure IsarThy: ISAR_THY =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    58
struct
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    59
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    60
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    61
(** derived theory and proof operations **)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    62
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    63
(* axioms and defs *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    64
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    65
fun attributize thy (x, srcs) = (x, map (Attrib.global_attribute thy) srcs);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    66
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    67
fun add_axioms axms thy = PureThy.add_axioms (map (attributize thy) axms) thy;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    68
fun add_defs defs thy = PureThy.add_defs (map (attributize thy) defs) thy;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    69
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    70
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    71
(* context *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    72
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    73
val fix = ProofHistory.apply o Proof.fix;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    74
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    75
val match_bind = ProofHistory.apply o Proof.match_bind;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    76
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    77
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    78
(* statements *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    79
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    80
fun global_statement f name tags s thy =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    81
  ProofHistory.init (f name (map (Attrib.global_attribute thy) tags) s thy);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    82
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    83
fun local_statement f name tags s = ProofHistory.apply_open (fn state =>
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    84
  f name (map (Attrib.local_attribute (Proof.theory_of state)) tags) s state);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    85
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    86
val theorem = global_statement Proof.theorem;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    87
val lemma = global_statement Proof.lemma;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    88
val assume = local_statement Proof.assume;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    89
val show = local_statement Proof.show;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    90
val have = local_statement Proof.have;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    91
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    92
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    93
(* forward chaining *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    94
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    95
val chain = ProofHistory.apply Proof.chain;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    96
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    97
fun from_facts names = ProofHistory.apply (fn state =>
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    98
  state
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
    99
  |> Proof.from_facts (ProofContext.get_tthmss (Proof.context_of state) names));
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   100
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   101
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   102
(* end proof *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   103
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   104
fun qed_with (alt_name, alt_tags) prf =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   105
  let
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   106
    val state = ProofHistory.current prf;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   107
    val thy = Proof.theory_of state;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   108
    val alt_atts = apsome (map (Attrib.global_attribute thy)) alt_tags;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   109
    val (thy', (kind, name, tthm)) = Method.qed alt_name alt_atts state;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   110
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   111
    val prt_result = Pretty.block
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   112
      [Pretty.str (kind ^ " " ^ name ^ ":"), Pretty.fbrk, Attribute.pretty_tthm tthm];
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   113
  in Pretty.writeln prt_result; thy end;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   114
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   115
val qed = qed_with (None, None);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   116
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   117
val kill_proof = Proof.theory_of o ProofHistory.current;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   118
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   119
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   120
(* blocks *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   121
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   122
val begin_block = ProofHistory.apply_open Proof.begin_block;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   123
val next_block = ProofHistory.apply Proof.next_block;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   124
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   125
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   126
(* backward steps *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   127
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   128
val tac = ProofHistory.applys o Method.tac;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   129
val etac = ProofHistory.applys o Method.etac;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   130
val proof = ProofHistory.applys o Method.proof;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   131
val end_block = ProofHistory.applys_close Method.end_block;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   132
val terminal_proof = ProofHistory.applys_close o Method.terminal_proof;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   133
val trivial_proof = ProofHistory.applys_close Method.trivial_proof;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   134
val default_proof = ProofHistory.applys_close Method.default_proof;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   135
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   136
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   137
(* use ML text *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   138
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   139
fun use_mltext txt opt_thy =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   140
  let
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   141
    val save_context = Context.get_context ();
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   142
    val _ = Context.set_context opt_thy;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   143
    val opt_exn = (transform_error (use_text false) txt; None) handle exn => Some exn;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   144
    val opt_thy' = Context.get_context ();
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   145
  in
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   146
    Context.set_context save_context;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   147
    (case opt_exn of
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   148
      None => opt_thy'
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   149
    | Some exn => raise exn)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   150
  end;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   151
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   152
fun use_mltext_theory txt thy =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   153
  (case use_mltext txt (Some thy) of
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   154
    Some thy' => thy'
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   155
  | None => error "Missing result ML theory context");
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   156
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   157
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   158
fun use_context txt = use_mltext_theory ("Context.>> (" ^ txt ^ ");");
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   159
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   160
fun use_let name body txt =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   161
  use_context ("let val " ^ name ^ " = " ^ txt ^ " in\n" ^ body ^ " end");
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   162
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   163
val use_setup =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   164
  use_let "setup: (theory -> theory) list" "Theory.apply setup";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   165
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   166
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   167
(* translation functions *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   168
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   169
val parse_ast_translation =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   170
  use_let "parse_ast_translation: (string * (Syntax.ast list -> Syntax.ast)) list"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   171
    "Theory.add_trfuns (parse_ast_translation, [], [], [])";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   172
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   173
val parse_translation =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   174
  use_let "parse_translation: (string * (term list -> term)) list"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   175
    "Theory.add_trfuns ([], parse_translation, [], [])";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   176
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   177
val print_translation =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   178
  use_let "print_translation: (string * (term list -> term)) list"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   179
    "Theory.add_trfuns ([], [], print_translation, [])";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   180
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   181
val print_ast_translation =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   182
  use_let "print_ast_translation: (string * (Syntax.ast list -> Syntax.ast)) list"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   183
    "Theory.add_trfuns ([], [], [], print_ast_translation)";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   184
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   185
val typed_print_translation =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   186
  use_let "typed_print_translation: (string * (bool -> typ -> term list -> term)) list"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   187
    "Theory.add_trfunsT typed_print_translation";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   188
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   189
val token_translation =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   190
  use_let "token_translation: (string * string * (string -> string * int)) list"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   191
    "Theory.add_tokentrfuns token_translation";
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   192
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   193
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   194
(* add_oracle *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   195
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   196
fun add_oracle (name, txt) =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   197
  use_let
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   198
    "oracle: bstring * (Sign.sg * Object.T -> term)"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   199
    "Theory.add_oracle oracle"
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   200
    ("(" ^ quote name ^ ", " ^ txt ^ ")");
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   201
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   202
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   203
(* theory init and exit *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   204
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   205
fun the_theory name () = ThyInfo.theory name;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   206
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   207
fun begin_theory (name, names) () =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   208
  PureThy.begin_theory name (map ThyInfo.theory names);
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   209
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   210
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   211
fun end_theory thy =
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   212
  let val thy' = PureThy.end_theory thy in
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   213
    transform_error ThyInfo.store_theory thy'
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   214
      handle exn => raise PureThy.ROLLBACK (thy', Some exn)     (* FIXME !!?? *)
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   215
  end;
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   216
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   217
95b619c7289b Derived theory operations.
wenzelm
parents:
diff changeset
   218
end;