| author | wenzelm | 
| Thu, 12 Jun 2008 18:54:29 +0200 | |
| changeset 27178 | c8ddb3000743 | 
| parent 25440 | aa25d4d59383 | 
| child 28066 | 611e504c1191 | 
| permissions | -rw-r--r-- | 
| 21637 | 1 | (* Title: Pure/ProofGeneral/preferences.ML | 
| 2 | ID: $Id$ | |
| 3 | Author: David Aspinall and Markus Wenzel | |
| 4 | ||
| 5 | User preferences for Isabelle which are maintained by the interface. | |
| 6 | *) | |
| 7 | ||
| 24329 | 8 | signature PREFERENCES = | 
| 21637 | 9 | sig | 
| 10 | type pgiptype = PgipTypes.pgiptype | |
| 11 | ||
| 12 |   type isa_preference = { name: string,
 | |
| 24329 | 13 | descr: string, | 
| 14 | default: string, | |
| 15 | pgiptype: pgiptype, | |
| 16 | get: unit -> string, | |
| 17 | set: string -> unit } | |
| 21637 | 18 | |
| 24191 | 19 | (* table of categories and preferences; names must be unique *) | 
| 22214 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 20 | type isa_preference_table = (string * isa_preference list) list | 
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 21 | |
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 22 | val preferences : isa_preference_table | 
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 23 | |
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 24 | val remove : string -> isa_preference_table -> isa_preference_table | 
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 25 | val set_default : string * string -> isa_preference_table -> isa_preference_table | 
| 21637 | 26 | end | 
| 27 | ||
| 28 | structure Preferences : PREFERENCES = | |
| 29 | struct | |
| 30 | ||
| 31 | val thm_depsN = "thm_deps"; (* also in proof_general_pgip.ML: move to pgip_isabelle? *) | |
| 32 | ||
| 33 | type pgiptype = PgipTypes.pgiptype | |
| 34 | ||
| 35 | type isa_preference = { name: string,
 | |
| 24329 | 36 | descr: string, | 
| 37 | default: string, | |
| 38 | pgiptype: pgiptype, | |
| 39 | get: unit -> string, | |
| 40 | set: string -> unit } | |
| 21637 | 41 | |
| 42 | ||
| 24329 | 43 | fun mkpref get set typ nm descr = | 
| 21637 | 44 |     { name=nm, descr=descr, pgiptype=typ, get=get, set=set, default=get() } : isa_preference
 | 
| 45 | ||
| 46 | fun mkpref_from_ref read write typ r nm descr = | |
| 47 | mkpref (fn()=> read (!r)) (fn v=> r:= (write v)) typ nm descr | |
| 48 | ||
| 24329 | 49 | val int_pref = | 
| 21637 | 50 | mkpref_from_ref PgipTypes.int_to_pgstring (PgipTypes.read_pgipint (NONE,NONE)) | 
| 24329 | 51 | (PgipTypes.Pgipint (NONE, NONE)) | 
| 21637 | 52 | val nat_pref = | 
| 53 | mkpref_from_ref PgipTypes.int_to_pgstring PgipTypes.read_pgipnat PgipTypes.Pgipnat | |
| 54 | ||
| 55 | val bool_pref = | |
| 56 | mkpref_from_ref PgipTypes.bool_to_pgstring PgipTypes.read_pgipbool PgipTypes.Pgipbool | |
| 57 | ||
| 58 | val proof_pref = | |
| 24329 | 59 | let | 
| 25223 | 60 | fun get () = PgipTypes.bool_to_pgstring (! Proofterm.proofs >= 2) | 
| 61 | fun set s = Proofterm.proofs := (if PgipTypes.read_pgipbool s then 2 else 1) | |
| 21637 | 62 | in | 
| 24329 | 63 | mkpref get set PgipTypes.Pgipbool "full-proofs" | 
| 64 | "Record full proof objects internally" | |
| 21637 | 65 | end | 
| 66 | ||
| 24329 | 67 | val thm_deps_pref = | 
| 68 | let | |
| 69 | fun get () = PgipTypes.bool_to_pgstring (print_mode_active thm_depsN) | |
| 24614 | 70 | fun set s = NAMED_CRITICAL "print_mode" (fn () => | 
| 71 | if PgipTypes.read_pgipbool s then | |
| 72 | change print_mode (insert (op =) thm_depsN) | |
| 73 | else | |
| 74 | change print_mode (remove (op =) thm_depsN)) | |
| 21637 | 75 | in | 
| 24329 | 76 | mkpref get set PgipTypes.Pgipbool "theorem-dependencies" | 
| 77 | "Track theorem dependencies within Proof General" | |
| 21637 | 78 | end | 
| 79 | ||
| 80 | val print_depth_pref = | |
| 24329 | 81 | let | 
| 82 | fun get () = PgipTypes.int_to_pgstring (get_print_depth ()) | |
| 83 | val set = print_depth o PgipTypes.read_pgipnat | |
| 21637 | 84 | in | 
| 24329 | 85 | mkpref get set PgipTypes.Pgipnat | 
| 86 | "print-depth" "Setting for the ML print depth" | |
| 21637 | 87 | end | 
| 88 | ||
| 89 | ||
| 24329 | 90 | val display_preferences = | 
| 21637 | 91 | [bool_pref show_types | 
| 24329 | 92 | "show-types" | 
| 93 | "Include types in display of Isabelle terms", | |
| 21637 | 94 | bool_pref show_sorts | 
| 24329 | 95 | "show-sorts" | 
| 96 | "Include sorts in display of Isabelle terms", | |
| 21637 | 97 | bool_pref show_consts | 
| 24329 | 98 | "show-consts" | 
| 99 | "Show types of consts in Isabelle goal display", | |
| 21637 | 100 | bool_pref long_names | 
| 24329 | 101 | "long-names" | 
| 102 | "Show fully qualified names in Isabelle terms", | |
| 21637 | 103 | bool_pref show_brackets | 
| 24329 | 104 | "show-brackets" | 
| 105 | "Show full bracketing in Isabelle terms", | |
| 21637 | 106 | bool_pref Proof.show_main_goal | 
| 24329 | 107 | "show-main-goal" | 
| 108 | "Show main goal in proof state display", | |
| 21637 | 109 | bool_pref Syntax.eta_contract | 
| 24329 | 110 | "eta-contract" | 
| 111 | "Print terms eta-contracted"] | |
| 21637 | 112 | |
| 113 | val advanced_display_preferences = | |
| 114 | [nat_pref goals_limit | |
| 24329 | 115 | "goals-limit" | 
| 116 | "Setting for maximum number of goals printed", | |
| 21637 | 117 | int_pref ProofContext.prems_limit | 
| 24329 | 118 | "prems-limit" | 
| 119 | "Setting for maximum number of premises printed", | |
| 120 | print_depth_pref, | |
| 21637 | 121 | bool_pref show_question_marks | 
| 24329 | 122 | "show-question-marks" | 
| 123 | "Show leading question mark of variable name"] | |
| 21637 | 124 | |
| 24329 | 125 | val tracing_preferences = | 
| 21637 | 126 | [bool_pref trace_simp | 
| 24329 | 127 | "trace-simplifier" | 
| 128 | "Trace simplification rules.", | |
| 21637 | 129 | nat_pref trace_simp_depth_limit | 
| 24329 | 130 | "trace-simplifier-depth" | 
| 131 | "Trace simplifier depth limit.", | |
| 21637 | 132 | bool_pref trace_rules | 
| 24329 | 133 | "trace-rules" | 
| 134 | "Trace application of the standard rules", | |
| 21637 | 135 | bool_pref Pattern.trace_unify_fail | 
| 24329 | 136 | "trace-unification" | 
| 137 | "Output error diagnostics during unification", | |
| 21637 | 138 | bool_pref Output.timing | 
| 24329 | 139 | "global-timing" | 
| 140 | "Whether to enable timing in Isabelle.", | |
| 22130 | 141 | bool_pref Toplevel.debug | 
| 24329 | 142 | "debugging" | 
| 24454 | 143 | "Whether to enable debugging.", | 
| 144 | bool_pref Codegen.auto_quickcheck | |
| 145 | "auto-quickcheck" | |
| 24806 | 146 | "Whether to enable quickcheck automatically.", | 
| 147 | nat_pref Codegen.auto_quickcheck_time_limit | |
| 148 | "auto-quickcheck-time-limit" | |
| 25440 
aa25d4d59383
Add thm_dep preference to menu, inadvertently missed off
 aspinall parents: 
25223diff
changeset | 149 | "Time limit for automatic quickcheck (in milliseconds).", | 
| 
aa25d4d59383
Add thm_dep preference to menu, inadvertently missed off
 aspinall parents: 
25223diff
changeset | 150 | thm_deps_pref] | 
| 21637 | 151 | |
| 24329 | 152 | val proof_preferences = | 
| 21637 | 153 | [bool_pref quick_and_dirty | 
| 24329 | 154 | "quick-and-dirty" | 
| 155 | "Take a few short cuts", | |
| 21637 | 156 | bool_pref Toplevel.skip_proofs | 
| 24329 | 157 | "skip-proofs" | 
| 158 | "Skip over proofs (interactive-only)", | |
| 24454 | 159 | proof_pref, | 
| 24100 | 160 | nat_pref Multithreading.max_threads | 
| 24329 | 161 | "max-threads" | 
| 162 | "Maximum number of threads"] | |
| 21637 | 163 | |
| 24329 | 164 | val preferences = | 
| 21637 | 165 |     [("Display", display_preferences),
 | 
| 166 |      ("Advanced Display", advanced_display_preferences),
 | |
| 167 |      ("Tracing", tracing_preferences),
 | |
| 168 |      ("Proof", proof_preferences)]
 | |
| 169 | ||
| 22214 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 170 | type isa_preference_table = (string * isa_preference list) list | 
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 171 | |
| 24329 | 172 | fun remove name (preftable : isa_preference_table) = | 
| 173 | map (fn (cat,prefs) => | |
| 174 | (cat, filter_out (curry op= name o #name) prefs)) | |
| 22214 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 175 | preftable; | 
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 176 | |
| 24329 | 177 | fun set_default (setname,newdefault) (preftable : isa_preference_table) = | 
| 178 | map (fn (cat,prefs) => | |
| 179 |             (cat, map (fn (pref as {name,descr,default,pgiptype,get,set})
 | |
| 180 | => if (name = setname) then | |
| 181 | (set newdefault; | |
| 182 |                                   {name=name,descr=descr,default=newdefault,
 | |
| 183 | pgiptype=pgiptype,get=get,set=set}) | |
| 184 | else pref) | |
| 185 | prefs)) | |
| 22214 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 186 | preftable; | 
| 
6e9ab159512f
Add operations on preference tables (remove, set_default).
 aspinall parents: 
22130diff
changeset | 187 | |
| 21637 | 188 | end |