src/Pure/Isar/isar_cmd.ML
author wenzelm
Tue, 26 Oct 1999 19:05:26 +0200
changeset 7936 cbeaff0ef856
parent 7931 fa6fec415492
child 8349 611342539639
permissions -rw-r--r--
added kill_proof_notify;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/isar_cmd.ML
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     4
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     5
Non-logical toplevel commands.
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     6
*)
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     7
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     8
signature ISAR_CMD =
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
     9
sig
7462
f738df1d82e1 added welcome;
wenzelm
parents: 7413
diff changeset
    10
  val welcome: Toplevel.transition -> Toplevel.transition
f738df1d82e1 added welcome;
wenzelm
parents: 7413
diff changeset
    11
  val init_toplevel: Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    12
  val exit: Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    13
  val quit: Toplevel.transition -> Toplevel.transition
7908
0b191b36ad97 added touch_child_thys;
wenzelm
parents: 7891
diff changeset
    14
  val touch_child_thys: string -> Toplevel.transition -> Toplevel.transition
7101
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    15
  val touch_all_thys: Toplevel.transition -> Toplevel.transition
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    16
  val touch_thy: string -> Toplevel.transition -> Toplevel.transition
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    17
  val remove_thy: string -> Toplevel.transition -> Toplevel.transition
7931
fa6fec415492 added kill_thy;
wenzelm
parents: 7908
diff changeset
    18
  val kill_thy: string -> Toplevel.transition -> Toplevel.transition
6734
151c07f5b70a cannot_undo;
wenzelm
parents: 6694
diff changeset
    19
  val cannot_undo: string -> Toplevel.transition -> Toplevel.transition
7729
81e001f143a4 replaced clear_undo by clear_undos;
wenzelm
parents: 7615
diff changeset
    20
  val clear_undos_theory: int -> Toplevel.transition -> Toplevel.transition
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    21
  val redo: Toplevel.transition -> Toplevel.transition
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    22
  val undos_proof: int -> Toplevel.transition -> Toplevel.transition
7936
cbeaff0ef856 added kill_proof_notify;
wenzelm
parents: 7931
diff changeset
    23
  val kill_proof_notify: (unit -> unit) -> Toplevel.transition -> Toplevel.transition
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    24
  val kill_proof: Toplevel.transition -> Toplevel.transition
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    25
  val undo_theory: Toplevel.transition -> Toplevel.transition
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    26
  val undo: Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    27
  val use: string -> Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    28
  val use_mltext_theory: string -> Toplevel.transition -> Toplevel.transition
7891
c77ad0c3c92f use_mltext: better control of verbosity;
wenzelm
parents: 7790
diff changeset
    29
  val use_mltext: bool -> string -> Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    30
  val use_commit: Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    31
  val cd: string -> Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    32
  val pwd: Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    33
  val use_thy: string -> Toplevel.transition -> Toplevel.transition
6694
335833a8b10a added use_thy_only;
wenzelm
parents: 6686
diff changeset
    34
  val use_thy_only: string -> Toplevel.transition -> Toplevel.transition
6195
62dc7e9050eb removed load;
wenzelm
parents: 6091
diff changeset
    35
  val update_thy: string -> Toplevel.transition -> Toplevel.transition
7101
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    36
  val update_thy_only: string -> Toplevel.transition -> Toplevel.transition
7124
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
    37
  val pretty_setmargin: int -> Toplevel.transition -> Toplevel.transition
7308
e01aab03a2a1 print_context;
wenzelm
parents: 7124
diff changeset
    38
  val print_context: Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    39
  val print_theory: Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    40
  val print_syntax: Toplevel.transition -> Toplevel.transition
5880
feec44106a8e add print_theorems;
wenzelm
parents: 5831
diff changeset
    41
  val print_theorems: Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    42
  val print_attributes: Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    43
  val print_methods: Toplevel.transition -> Toplevel.transition
7615
c650147f56f1 added print_thms_containing;
wenzelm
parents: 7503
diff changeset
    44
  val print_thms_containing: xstring list -> Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    45
  val print_binds: Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    46
  val print_lthms: Toplevel.transition -> Toplevel.transition
7012
ae9dac5af9d1 improved print_thms;
wenzelm
parents: 6742
diff changeset
    47
  val print_thms: (string * Args.src list) list -> Toplevel.transition -> Toplevel.transition
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    48
  val print_prop: string -> Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    49
  val print_term: string -> Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    50
  val print_type: string -> Toplevel.transition -> Toplevel.transition
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    51
end;
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    52
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    53
structure IsarCmd: ISAR_CMD =
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    54
struct
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    55
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    56
7462
f738df1d82e1 added welcome;
wenzelm
parents: 7413
diff changeset
    57
(* variations on init / exit *)
f738df1d82e1 added welcome;
wenzelm
parents: 7413
diff changeset
    58
f738df1d82e1 added welcome;
wenzelm
parents: 7413
diff changeset
    59
val init_toplevel = Toplevel.imperative (fn () => raise Toplevel.RESTART);
f738df1d82e1 added welcome;
wenzelm
parents: 7413
diff changeset
    60
val welcome = Toplevel.imperative (writeln o Session.welcome);
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    61
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    62
val exit = Toplevel.keep (fn state =>
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    63
  (Context.set_context (try Toplevel.theory_of state);
6635
f81b9b4c3265 fixed msg;
wenzelm
parents: 6264
diff changeset
    64
    writeln "Leaving the Isar loop.  Invoke 'loop();' to restart.";
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    65
    raise Toplevel.TERMINATE));
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    66
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    67
val quit = Toplevel.imperative quit;
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    68
7101
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    69
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    70
(* touch theories *)
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    71
7908
0b191b36ad97 added touch_child_thys;
wenzelm
parents: 7891
diff changeset
    72
fun touch_child_thys name = Toplevel.imperative (fn () => ThyInfo.touch_child_thys name);
7101
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    73
val touch_all_thys = Toplevel.imperative ThyInfo.touch_all_thys;
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    74
fun touch_thy name = Toplevel.imperative (fn () => ThyInfo.touch_thy name);
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    75
fun remove_thy name = Toplevel.imperative (fn () => ThyInfo.remove_thy name);
7931
fa6fec415492 added kill_thy;
wenzelm
parents: 7908
diff changeset
    76
fun kill_thy name = Toplevel.imperative (fn () => IsarThy.kill_theory name);
7101
ee79bf6feee2 removed restart;
wenzelm
parents: 7023
diff changeset
    77
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
    78
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    79
(* history commands *)
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    80
6734
151c07f5b70a cannot_undo;
wenzelm
parents: 6694
diff changeset
    81
fun cannot_undo txt = Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt));
7729
81e001f143a4 replaced clear_undo by clear_undos;
wenzelm
parents: 7615
diff changeset
    82
val clear_undos_theory = Toplevel.history o History.clear;
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    83
val redo = Toplevel.history History.redo o Toplevel.proof ProofHistory.redo;
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    84
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    85
fun undos_proof n = Toplevel.proof (fn prf =>
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    86
  if ProofHistory.is_initial prf then raise Toplevel.UNDEF else funpow n ProofHistory.undo prf);
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    87
7936
cbeaff0ef856 added kill_proof_notify;
wenzelm
parents: 7931
diff changeset
    88
fun kill_proof_notify (f: unit -> unit) = Toplevel.history (fn hist =>
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    89
  (case History.current hist of
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    90
    Toplevel.Theory _ => raise Toplevel.UNDEF
7936
cbeaff0ef856 added kill_proof_notify;
wenzelm
parents: 7931
diff changeset
    91
  | Toplevel.Proof _ => (f (); History.undo hist)));
cbeaff0ef856 added kill_proof_notify;
wenzelm
parents: 7931
diff changeset
    92
cbeaff0ef856 added kill_proof_notify;
wenzelm
parents: 7931
diff changeset
    93
val kill_proof = kill_proof_notify (K ());
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    94
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    95
val undo_theory = Toplevel.history (fn hist =>
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6734
diff changeset
    96
  if History.is_initial hist then raise Toplevel.UNDEF else History.undo hist);
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    97
7413
e25ad9ab0b50 removed kill_theory;
wenzelm
parents: 7308
diff changeset
    98
val undo = Toplevel.kill o undo_theory o undos_proof 1;
6686
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
    99
08b06cd19f8d history commands;
wenzelm
parents: 6662
diff changeset
   100
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   101
(* use ML text *)
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   102
6264
87e5f5b40595 use: provide context;
wenzelm
parents: 6243
diff changeset
   103
fun use name = Toplevel.keep (fn state =>
87e5f5b40595 use: provide context;
wenzelm
parents: 6243
diff changeset
   104
  Context.setmp (try Toplevel.theory_of state) ThyInfo.use name);
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   105
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   106
(*passes changes of theory context*)
7615
c650147f56f1 added print_thms_containing;
wenzelm
parents: 7503
diff changeset
   107
val use_mltext_theory = Toplevel.theory' o IsarThy.use_mltext_theory;
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   108
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   109
(*ignore result theory context*)
7891
c77ad0c3c92f use_mltext: better control of verbosity;
wenzelm
parents: 7790
diff changeset
   110
fun use_mltext v txt = Toplevel.keep' (fn verb => fn state =>
c77ad0c3c92f use_mltext: better control of verbosity;
wenzelm
parents: 7790
diff changeset
   111
  (IsarThy.use_mltext txt (v andalso verb) (try Toplevel.theory_of state)));
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   112
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   113
(*Note: commit is dynamically bound*)
7891
c77ad0c3c92f use_mltext: better control of verbosity;
wenzelm
parents: 7790
diff changeset
   114
val use_commit = use_mltext false "commit();";
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   115
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   116
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   117
(* current working directory *)
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   118
7790
2fd4d53acc0a cd: quiet;
wenzelm
parents: 7729
diff changeset
   119
fun cd dir = Toplevel.imperative (fn () => (File.cd (Path.unpack dir)));
2fd4d53acc0a cd: quiet;
wenzelm
parents: 7729
diff changeset
   120
val pwd = Toplevel.imperative (fn () => writeln (Path.pack (File.pwd ())));
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   121
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   122
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   123
(* load theory files *)
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   124
6243
fb293dfa2df3 use_thy, update_thy: Context.save;
wenzelm
parents: 6228
diff changeset
   125
fun use_thy name = Toplevel.imperative (fn () => Context.save ThyInfo.use_thy name);
6694
335833a8b10a added use_thy_only;
wenzelm
parents: 6686
diff changeset
   126
fun use_thy_only name = Toplevel.imperative (fn () => Context.save ThyInfo.use_thy_only name);
6243
fb293dfa2df3 use_thy, update_thy: Context.save;
wenzelm
parents: 6228
diff changeset
   127
fun update_thy name = Toplevel.imperative (fn () => Context.save ThyInfo.update_thy name);
7124
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   128
fun update_thy_only name =
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   129
  Toplevel.imperative (fn () => Context.save ThyInfo.update_thy_only name);
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   130
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   131
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   132
(* pretty_setmargin *)
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   133
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7101
diff changeset
   134
fun pretty_setmargin n = Toplevel.imperative (fn () => Pretty.setmargin n);
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   135
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   136
7308
e01aab03a2a1 print_context;
wenzelm
parents: 7124
diff changeset
   137
(* print theory *)
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   138
7308
e01aab03a2a1 print_context;
wenzelm
parents: 7124
diff changeset
   139
val print_context = Toplevel.keep Toplevel.print_state_context;
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   140
val print_theory = Toplevel.keep (PureThy.print_theory o Toplevel.theory_of);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   141
val print_syntax = Toplevel.keep (Display.print_syntax o Toplevel.theory_of);
5880
feec44106a8e add print_theorems;
wenzelm
parents: 5831
diff changeset
   142
val print_theorems = Toplevel.keep (PureThy.print_theorems o Toplevel.theory_of);
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   143
val print_attributes = Toplevel.keep (Attrib.print_attributes o Toplevel.theory_of);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   144
val print_methods = Toplevel.keep (Method.print_methods o Toplevel.theory_of);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   145
7615
c650147f56f1 added print_thms_containing;
wenzelm
parents: 7503
diff changeset
   146
fun print_thms_containing cs = Toplevel.keep (fn state =>
c650147f56f1 added print_thms_containing;
wenzelm
parents: 7503
diff changeset
   147
  ThmDatabase.print_thms_containing (Toplevel.theory_of state) cs);
c650147f56f1 added print_thms_containing;
wenzelm
parents: 7503
diff changeset
   148
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   149
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   150
(* print proof context contents *)
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   151
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   152
val print_binds = Toplevel.keep (ProofContext.print_binds o Proof.context_of o Toplevel.proof_of);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   153
val print_lthms = Toplevel.keep (ProofContext.print_thms o Proof.context_of o Toplevel.proof_of);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   154
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   155
7012
ae9dac5af9d1 improved print_thms;
wenzelm
parents: 6742
diff changeset
   156
(* print theorems / types / terms / props *)
5880
feec44106a8e add print_theorems;
wenzelm
parents: 5831
diff changeset
   157
7012
ae9dac5af9d1 improved print_thms;
wenzelm
parents: 6742
diff changeset
   158
fun print_thms args = Toplevel.keep (fn state =>
ae9dac5af9d1 improved print_thms;
wenzelm
parents: 6742
diff changeset
   159
  let val st = Toplevel.node_case Proof.init_state Proof.enter_forward state
7413
e25ad9ab0b50 removed kill_theory;
wenzelm
parents: 7308
diff changeset
   160
  in Pretty.writeln (Proof.pretty_thms (IsarThy.get_thmss args st)) end);
5895
457b42674b57 added print_thm;
wenzelm
parents: 5880
diff changeset
   161
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   162
fun print_type s = Toplevel.keep (fn state =>
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   163
  let
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   164
    val sign = Toplevel.sign_of state;
7503
e8be98558eb8 read_typ/term: context_of;
wenzelm
parents: 7462
diff changeset
   165
    val T = ProofContext.read_typ (Toplevel.context_of state) s;
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   166
  in Pretty.writeln (Pretty.quote (Sign.pretty_typ sign T)) end);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   167
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   168
fun print_term s = Toplevel.keep (fn state =>
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   169
  let
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   170
    val sign = Toplevel.sign_of state;
7503
e8be98558eb8 read_typ/term: context_of;
wenzelm
parents: 7462
diff changeset
   171
    val t = ProofContext.read_term (Toplevel.context_of state) s;
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   172
    val T = Term.type_of t;
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   173
  in
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   174
    Pretty.writeln (Pretty.block [Pretty.quote (Sign.pretty_term sign t), Pretty.fbrk,
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   175
      Pretty.str "::", Pretty.brk 1, Pretty.quote (Sign.pretty_typ sign T)])
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   176
  end);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   177
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   178
fun print_prop s = Toplevel.keep (fn state =>
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   179
  let
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   180
    val sign = Toplevel.sign_of state;
7503
e8be98558eb8 read_typ/term: context_of;
wenzelm
parents: 7462
diff changeset
   181
    val prop = ProofContext.read_prop (Toplevel.context_of state) s;
5831
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   182
  in Pretty.writeln (Pretty.quote (Sign.pretty_term sign prop)) end);
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   183
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   184
996361157cfb Non-logical toplevel commands.
wenzelm
parents:
diff changeset
   185
end;