| author | paulson | 
| Wed, 28 Jun 2000 10:56:01 +0200 | |
| changeset 9172 | 2dbb80d4fdb7 | 
| parent 9007 | 135c998d2b46 | 
| child 9192 | df32cd0881b9 | 
| permissions | -rw-r--r-- | 
| 3987 | 1 | (* Title: Pure/pure_thy.ML | 
| 2 | ID: $Id$ | |
| 3 | Author: Markus Wenzel, TU Muenchen | |
| 4 | ||
| 5091 | 5 | Theorem database, derived theory operations, and the ProtoPure theory. | 
| 3987 | 6 | *) | 
| 7 | ||
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 8 | signature BASIC_PURE_THY = | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 9 | sig | 
| 5000 | 10 | val print_theorems: theory -> unit | 
| 11 | val print_theory: theory -> unit | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 12 | val get_thm: theory -> xstring -> thm | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 13 | val get_thms: theory -> xstring -> thm list | 
| 6094 | 14 | val get_thmss: theory -> xstring list -> thm list | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 15 | val thms_of: theory -> (string * thm) list | 
| 5091 | 16 | structure ProtoPure: | 
| 17 | sig | |
| 18 | val thy: theory | |
| 19 | val flexpair_def: thm | |
| 20 | val Goal_def: thm | |
| 21 | end | |
| 4853 | 22 | end; | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 23 | |
| 3987 | 24 | signature PURE_THY = | 
| 25 | sig | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 26 | include BASIC_PURE_THY | 
| 6367 | 27 | val cond_extern_thm_sg: Sign.sg -> string -> xstring | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 28 | val thms_containing: theory -> string list -> (string * thm) list | 
| 6091 | 29 | val store_thm: (bstring * thm) * theory attribute list -> theory -> theory * thm | 
| 7405 | 30 | val smart_store_thms: (bstring * thm list) -> thm list | 
| 7899 | 31 | val forall_elim_var: int -> thm -> thm | 
| 32 | val forall_elim_vars: int -> thm -> thm | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 33 | val add_thms: ((bstring * thm) * theory attribute list) list -> theory -> theory * thm list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 34 | val add_thmss: ((bstring * thm list) * theory attribute list) list -> theory -> theory * thm list list | 
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 35 | val have_thmss: bstring -> theory attribute list -> | 
| 6091 | 36 | (thm list * theory attribute list) list -> theory -> theory * thm list | 
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 37 | val add_axioms: ((bstring * string) * theory attribute list) list -> theory -> theory * thm list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 38 | val add_axioms_i: ((bstring * term) * theory attribute list) list -> theory -> theory * thm list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 39 | val add_axiomss: ((bstring * string list) * theory attribute list) list -> theory -> theory * thm list list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 40 | val add_axiomss_i: ((bstring * term list) * theory attribute list) list -> theory -> theory * thm list list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 41 | val add_defs: ((bstring * string) * theory attribute list) list -> theory -> theory * thm list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 42 | val add_defs_i: ((bstring * term) * theory attribute list) list -> theory -> theory * thm list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 43 | val add_defss: ((bstring * string list) * theory attribute list) list -> theory -> theory * thm list list | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 44 | val add_defss_i: ((bstring * term list) * theory attribute list) list -> theory -> theory * thm list list | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 45 | val get_name: theory -> string | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 46 | val put_name: string -> theory -> theory | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 47 | val global_path: theory -> theory | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 48 | val local_path: theory -> theory | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 49 | val begin_theory: string -> theory list -> theory | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 50 | val end_theory: theory -> theory | 
| 6682 | 51 | val checkpoint: theory -> theory | 
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 52 | val add_typedecls: (bstring * string list * mixfix) list -> theory -> theory | 
| 6560 
1436349f8b28
renamed 'dummy' to 'dummy_pattern' (less dangerous);
 wenzelm parents: 
6547diff
changeset | 53 | val dummy_patternN: string | 
| 3987 | 54 | end; | 
| 55 | ||
| 56 | structure PureThy: PURE_THY = | |
| 57 | struct | |
| 58 | ||
| 59 | ||
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 60 | (*** theorem database ***) | 
| 3987 | 61 | |
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 62 | (** data kind 'Pure/theorems' **) | 
| 3987 | 63 | |
| 5005 | 64 | structure TheoremsDataArgs = | 
| 65 | struct | |
| 66 | val name = "Pure/theorems"; | |
| 3987 | 67 | |
| 5005 | 68 | type T = | 
| 69 |     {space: NameSpace.T,
 | |
| 6091 | 70 | thms_tab: thm list Symtab.table, | 
| 71 | const_idx: int * (int * thm) list Symtab.table} ref; | |
| 3987 | 72 | |
| 4853 | 73 | fun mk_empty _ = | 
| 5005 | 74 |     ref {space = NameSpace.empty, thms_tab = Symtab.empty, const_idx = (0, Symtab.empty)} : T;
 | 
| 3987 | 75 | |
| 5005 | 76 | val empty = mk_empty (); | 
| 6547 | 77 | fun copy (ref x) = ref x; | 
| 5005 | 78 | val prep_ext = mk_empty; | 
| 79 | val merge = mk_empty; | |
| 80 | ||
| 8720 | 81 |   fun pretty sg (ref {space, thms_tab, const_idx = _}) =
 | 
| 4853 | 82 | let | 
| 6091 | 83 | val prt_thm = Display.pretty_thm o Thm.transfer_sg sg; | 
| 4853 | 84 | fun prt_thms (name, [th]) = | 
| 85 | Pretty.block [Pretty.str (name ^ ":"), Pretty.brk 1, prt_thm th] | |
| 86 | | prt_thms (name, ths) = Pretty.big_list (name ^ ":") (map prt_thm ths); | |
| 3987 | 87 | |
| 6846 | 88 | val thmss = NameSpace.cond_extern_table space thms_tab; | 
| 4853 | 89 | in | 
| 8720 | 90 |       [Display.pretty_name_space ("theorem name space", space),
 | 
| 91 | Pretty.big_list "theorems:" (map prt_thms thmss)] | |
| 4853 | 92 | end; | 
| 8720 | 93 | |
| 94 | fun print sg data = Pretty.writeln (Pretty.chunks (pretty sg data)); | |
| 3987 | 95 | end; | 
| 96 | ||
| 5005 | 97 | structure TheoremsData = TheoryDataFun(TheoremsDataArgs); | 
| 98 | val get_theorems_sg = TheoremsData.get_sg; | |
| 99 | val get_theorems = TheoremsData.get; | |
| 100 | ||
| 6367 | 101 | val cond_extern_thm_sg = NameSpace.cond_extern o #space o ! o get_theorems_sg; | 
| 102 | ||
| 3987 | 103 | |
| 5000 | 104 | (* print theory *) | 
| 3987 | 105 | |
| 5005 | 106 | val print_theorems = TheoremsData.print; | 
| 8720 | 107 | |
| 5000 | 108 | fun print_theory thy = | 
| 8720 | 109 | Display.pretty_full_theory thy @ TheoremsDataArgs.pretty (Theory.sign_of thy) (get_theorems thy) | 
| 110 | |> Pretty.chunks |> Pretty.writeln; | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 111 | |
| 3987 | 112 | |
| 113 | ||
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 114 | (** retrieve theorems **) | 
| 3987 | 115 | |
| 4783 | 116 | (* get_thms etc. *) | 
| 4037 | 117 | |
| 7485 | 118 | fun lookup_thms name thy = | 
| 119 |   let val ref {space, thms_tab, ...} = get_theorems thy
 | |
| 120 | in Symtab.lookup (thms_tab, NameSpace.intern space name) end; | |
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 121 | |
| 6091 | 122 | fun get_thms thy name = | 
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 123 | (case get_first (lookup_thms name) (thy :: Theory.ancestors_of thy) of | 
| 4590 | 124 |     None => raise THEORY ("Unknown theorem(s) " ^ quote name, [thy])
 | 
| 9007 | 125 | | Some thms => map (Thm.transfer thy) thms); | 
| 3987 | 126 | |
| 6091 | 127 | fun get_thm thy name = | 
| 128 | (case get_thms thy name of | |
| 3987 | 129 | [thm] => thm | 
| 4590 | 130 |   | _ => raise THEORY ("Single theorem expected " ^ quote name, [thy]));
 | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 131 | |
| 6091 | 132 | fun get_thmss thy names = flat (map (get_thms thy) names); | 
| 4783 | 133 | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 134 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 135 | (* thms_of *) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 136 | |
| 6091 | 137 | fun attach_name thm = (Thm.name_of_thm thm, thm); | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 138 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 139 | fun thms_of thy = | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 140 |   let val ref {thms_tab, ...} = get_theorems thy in
 | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 141 | map attach_name (flat (map snd (Symtab.dest thms_tab))) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 142 | end; | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 143 | |
| 3987 | 144 | |
| 145 | ||
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 146 | (** theorems indexed by constants **) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 147 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 148 | (* make index *) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 149 | |
| 6091 | 150 | fun add_const_idx ((next, table), thm) = | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 151 | let | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 152 |     val {hyps, prop, ...} = Thm.rep_thm thm;
 | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 153 | val consts = | 
| 7805 
0ae9ddc36fe0
theorem database now also indexes constants "Trueprop", "all",
 wenzelm parents: 
7753diff
changeset | 154 | foldr add_term_consts (hyps, add_term_consts (prop, [])); | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 155 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 156 | fun add (tab, c) = | 
| 6091 | 157 | Symtab.update ((c, (next, thm) :: Symtab.lookup_multi (tab, c)), tab); | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 158 | in (next + 1, foldl add (table, consts)) end; | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 159 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 160 | fun make_const_idx thm_tab = | 
| 5686 | 161 | Symtab.foldl (fn (x, (_, ths)) => foldl add_const_idx (x, ths)) ((0, Symtab.empty), thm_tab); | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 162 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 163 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 164 | (* lookup index *) | 
| 3987 | 165 | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 166 | (*search locally*) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 167 | fun containing [] thy = thms_of thy | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 168 | | containing consts thy = | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 169 | let | 
| 4037 | 170 | fun int ([], _) = [] | 
| 171 | | int (_, []) = [] | |
| 172 | | int (xxs as ((x as (i:int, _)) :: xs), yys as ((y as (j, _)) :: ys)) = | |
| 173 | if i = j then x :: int (xs, ys) | |
| 174 | else if i > j then int (xs, yys) | |
| 175 | else int (xxs, ys); | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 176 | |
| 4037 | 177 | fun ints [xs] = xs | 
| 178 | | ints xss = if exists null xss then [] else foldl int (hd xss, tl xss); | |
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 179 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 180 |         val ref {const_idx = (_, ctab), ...} = get_theorems thy;
 | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 181 | val ithmss = map (fn c => Symtab.lookup_multi (ctab, c)) consts; | 
| 6977 | 182 | in map (attach_name o snd) (ints ithmss) end; | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 183 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 184 | (*search globally*) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 185 | fun thms_containing thy consts = | 
| 6977 | 186 | (case filter (is_none o Sign.const_type (Theory.sign_of thy)) consts of | 
| 7805 
0ae9ddc36fe0
theorem database now also indexes constants "Trueprop", "all",
 wenzelm parents: 
7753diff
changeset | 187 | [] => flat (map (containing consts) (thy :: Theory.ancestors_of thy)) | 
| 6977 | 188 |   | cs => raise THEORY ("thms_containing: undeclared consts " ^ commas_quote cs, [thy]));
 | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 189 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 190 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 191 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 192 | (** store theorems **) (*DESTRUCTIVE*) | 
| 3987 | 193 | |
| 4853 | 194 | (* naming *) | 
| 195 | ||
| 196 | fun gen_names len name = | |
| 197 | map (fn i => name ^ "_" ^ string_of_int i) (1 upto len); | |
| 198 | ||
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 199 | fun name_single name x = [(name, x)]; | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 200 | fun name_multi name xs = gen_names (length xs) name ~~ xs; | 
| 4853 | 201 | |
| 202 | ||
| 6091 | 203 | (* enter_thmx *) | 
| 4853 | 204 | |
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 205 | fun warn_overwrite name = warning ("Replaced old copy of theorems " ^ quote name);
 | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 206 | fun warn_same name = warning ("Theorem database already contains a copy of " ^ quote name);
 | 
| 3987 | 207 | |
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 208 | fun enter_thmx _ app_name ("", thmx) = map #2 (app_name "" thmx)
 | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 209 | | enter_thmx sg app_name (bname, thmx) = | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 210 | let | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 211 | val name = Sign.full_name sg bname; | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 212 | val named_thms = map Thm.name_thm (app_name name thmx); | 
| 3987 | 213 | |
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 214 |         val r as ref {space, thms_tab, const_idx} = get_theorems_sg sg;
 | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 215 | |
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 216 | val overwrite = | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 217 | (case Symtab.lookup (thms_tab, name) of | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 218 | None => false | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 219 | | Some thms' => | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 220 | if Library.equal_lists Thm.eq_thm (thms', named_thms) then (warn_same name; false) | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 221 | else (warn_overwrite name; true)); | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 222 | |
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 223 | val space' = NameSpace.extend (space, [name]); | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 224 | val thms_tab' = Symtab.update ((name, named_thms), thms_tab); | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 225 | val const_idx' = | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 226 | if overwrite then make_const_idx thms_tab' | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 227 | else foldl add_const_idx (const_idx, named_thms); | 
| 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 228 |       in r := {space = space', thms_tab = thms_tab', const_idx = const_idx'}; named_thms end;
 | 
| 3987 | 229 | |
| 4853 | 230 | |
| 6091 | 231 | (* add_thms(s) *) | 
| 4853 | 232 | |
| 6091 | 233 | fun add_thmx app_name app_att ((bname, thmx), atts) thy = | 
| 5280 | 234 | let | 
| 6091 | 235 | val (thy', thmx') = app_att ((thy, thmx), atts); | 
| 236 | val thms'' = enter_thmx (Theory.sign_of thy') app_name (bname, thmx'); | |
| 237 | in (thy', thms'') end; | |
| 4853 | 238 | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 239 | fun add_thms args theory = | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 240 | (theory, args) | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 241 | |> foldl_map (fn (thy, arg) => add_thmx name_single Thm.apply_attributes arg thy) | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 242 | |> apsnd (map hd); | 
| 5907 | 243 | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 244 | fun add_thmss args theory = | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 245 | (theory, args) | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 246 | |> foldl_map (fn (thy, arg) => add_thmx name_multi Thm.applys_attributes arg thy); | 
| 5907 | 247 | |
| 248 | ||
| 6091 | 249 | (* have_thmss *) | 
| 5907 | 250 | |
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 251 | fun have_thmss bname more_atts ths_atts thy = | 
| 5907 | 252 | let | 
| 6091 | 253 | fun app (x, (ths, atts)) = Thm.applys_attributes ((x, ths), atts); | 
| 254 | val (thy', thmss') = | |
| 5907 | 255 | foldl_map app (thy, map (fn (ths, atts) => (ths, atts @ more_atts)) ths_atts); | 
| 6367 | 256 | val thms' = flat thmss'; | 
| 7470 
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
 wenzelm parents: 
7405diff
changeset | 257 | val thms'' = enter_thmx (Theory.sign_of thy') name_multi (bname, thms'); | 
| 6769 | 258 | in (thy', thms'') end; | 
| 5280 | 259 | |
| 260 | ||
| 6091 | 261 | (* store_thm *) | 
| 5280 | 262 | |
| 6091 | 263 | fun store_thm th_atts thy = | 
| 264 | let val (thy', [th']) = add_thmx name_single Thm.apply_attributes th_atts thy | |
| 5280 | 265 | in (thy', th') end; | 
| 3987 | 266 | |
| 267 | ||
| 7405 | 268 | (* smart_store_thms *) | 
| 3987 | 269 | |
| 7405 | 270 | fun smart_store_thms (name, []) = error ("Cannot store empty list of theorems: " ^ quote name)
 | 
| 271 | | smart_store_thms (name, [thm]) = enter_thmx (Thm.sign_of_thm thm) name_single (name, thm) | |
| 272 | | smart_store_thms (name, thms) = | |
| 273 | let | |
| 274 | val merge_sg = Sign.merge_refs o apsnd (Sign.self_ref o Thm.sign_of_thm); | |
| 275 | val sg_ref = foldl merge_sg (Sign.self_ref (Thm.sign_of_thm (hd thms)), tl thms); | |
| 276 | in enter_thmx (Sign.deref sg_ref) name_multi (name, thms) end; | |
| 3987 | 277 | |
| 278 | ||
| 7899 | 279 | (* forall_elim_vars (belongs to drule.ML) *) | 
| 280 | ||
| 281 | (*Replace outermost quantified variable by Var of given index. | |
| 282 | Could clash with Vars already present.*) | |
| 283 | fun forall_elim_var i th = | |
| 284 |     let val {prop,sign,...} = rep_thm th
 | |
| 285 | in case prop of | |
| 286 |           Const("all",_) $ Abs(a,T,_) =>
 | |
| 287 | forall_elim (cterm_of sign (Var((a,i), T))) th | |
| 288 |         | _ => raise THM("forall_elim_var", i, [th])
 | |
| 289 | end; | |
| 290 | ||
| 291 | (*Repeat forall_elim_var until all outer quantifiers are removed*) | |
| 292 | fun forall_elim_vars i th = | |
| 293 | forall_elim_vars i (forall_elim_var i th) | |
| 294 | handle THM _ => th; | |
| 295 | ||
| 296 | ||
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 297 | (* store axioms as theorems *) | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 298 | |
| 4853 | 299 | local | 
| 7899 | 300 | fun get_axs thy named_axs = | 
| 301 | map (forall_elim_vars 0 o Thm.get_axiom thy o fst) named_axs; | |
| 7753 | 302 | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 303 | fun add_single add (thy, ((name, ax), atts)) = | 
| 4853 | 304 | let | 
| 7753 | 305 | val named_ax = name_single name ax; | 
| 306 | val thy' = add named_ax thy; | |
| 307 | val thm = hd (get_axs thy' named_ax); | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 308 | in apsnd hd (add_thms [((name, thm), atts)] thy') end; | 
| 7753 | 309 | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 310 | fun add_multi add (thy, ((name, axs), atts)) = | 
| 7753 | 311 | let | 
| 312 | val named_axs = name_multi name axs; | |
| 4853 | 313 | val thy' = add named_axs thy; | 
| 7753 | 314 | val thms = get_axs thy' named_axs; | 
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 315 | in apsnd hd (add_thmss [((name, thms), atts)] thy') end; | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 316 | |
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 317 | fun add_singles add args thy = foldl_map (add_single add) (thy, args); | 
| 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 318 | fun add_multis add args thy = foldl_map (add_multi add) (thy, args); | 
| 4853 | 319 | in | 
| 7753 | 320 | val add_axioms = add_singles Theory.add_axioms; | 
| 321 | val add_axioms_i = add_singles Theory.add_axioms_i; | |
| 322 | val add_axiomss = add_multis Theory.add_axioms; | |
| 323 | val add_axiomss_i = add_multis Theory.add_axioms_i; | |
| 324 | val add_defs = add_singles Theory.add_defs; | |
| 325 | val add_defs_i = add_singles Theory.add_defs_i; | |
| 326 | val add_defss = add_multis Theory.add_defs; | |
| 327 | val add_defss_i = add_multis Theory.add_defs_i; | |
| 4853 | 328 | end; | 
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 329 | |
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 330 | |
| 3987 | 331 | |
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 332 | (*** derived theory operations ***) | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 333 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 334 | (** theory management **) | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 335 | |
| 5005 | 336 | (* data kind 'Pure/theory_management' *) | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 337 | |
| 5005 | 338 | structure TheoryManagementDataArgs = | 
| 339 | struct | |
| 340 | val name = "Pure/theory_management"; | |
| 6660 | 341 |   type T = {name: string, version: int};
 | 
| 5000 | 342 | |
| 6660 | 343 |   val empty = {name = "", version = 0};
 | 
| 6547 | 344 | val copy = I; | 
| 5005 | 345 | val prep_ext = I; | 
| 5000 | 346 | fun merge _ = empty; | 
| 5005 | 347 | fun print _ _ = (); | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 348 | end; | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 349 | |
| 5005 | 350 | structure TheoryManagementData = TheoryDataFun(TheoryManagementDataArgs); | 
| 351 | val get_info = TheoryManagementData.get; | |
| 352 | val put_info = TheoryManagementData.put; | |
| 353 | ||
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 354 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 355 | (* get / put name *) | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 356 | |
| 5000 | 357 | val get_name = #name o get_info; | 
| 6660 | 358 | fun put_name name = put_info {name = name, version = 0};
 | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 359 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 360 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 361 | (* control prefixing of theory name *) | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 362 | |
| 5210 | 363 | val global_path = Theory.root_path; | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 364 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 365 | fun local_path thy = | 
| 5210 | 366 | thy |> Theory.root_path |> Theory.add_path (get_name thy); | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 367 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 368 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 369 | (* begin / end theory *) | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 370 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 371 | fun begin_theory name thys = | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 372 | Theory.prep_ext_merge thys | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 373 | |> put_name name | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 374 | |> local_path; | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 375 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 376 | fun end_theory thy = Theory.add_name (get_name thy) thy; | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 377 | |
| 6682 | 378 | fun checkpoint thy = | 
| 379 | if is_draft thy then | |
| 380 |     let val {name, version} = get_info thy in
 | |
| 381 | thy | |
| 382 | |> Theory.add_name (name ^ ":" ^ string_of_int version) | |
| 383 |       |> put_info {name = name, version = version + 1}
 | |
| 384 | end | |
| 385 | else thy; | |
| 5000 | 386 | |
| 387 | ||
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 388 | |
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 389 | (** add logical types **) | 
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 390 | |
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 391 | fun add_typedecls decls thy = | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 392 | let | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 393 | val full = Sign.full_name (Theory.sign_of thy); | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 394 | |
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 395 | fun type_of (raw_name, vs, mx) = | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 396 | if null (duplicates vs) then (raw_name, length vs, mx) | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 397 |       else error ("Duplicate parameters in type declaration: " ^ quote raw_name);
 | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 398 | |
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 399 | fun arity_of (raw_name, len, mx) = | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 400 | (full (Syntax.type_name raw_name mx), replicate len logicS, logicS); | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 401 | |
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 402 | val types = map type_of decls; | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 403 | val arities = map arity_of types; | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 404 | in | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 405 | thy | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 406 | |> Theory.add_types types | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 407 | |> Theory.add_arities_i arities | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 408 | end; | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 409 | |
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 410 | |
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 411 | |
| 5091 | 412 | (*** the ProtoPure theory ***) | 
| 3987 | 413 | |
| 6560 
1436349f8b28
renamed 'dummy' to 'dummy_pattern' (less dangerous);
 wenzelm parents: 
6547diff
changeset | 414 | val dummy_patternN = "dummy_pattern"; | 
| 
1436349f8b28
renamed 'dummy' to 'dummy_pattern' (less dangerous);
 wenzelm parents: 
6547diff
changeset | 415 | |
| 3987 | 416 | val proto_pure = | 
| 417 | Theory.pre_pure | |
| 5907 | 418 | |> Library.apply [TheoremsData.init, TheoryManagementData.init] | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 419 | |> put_name "ProtoPure" | 
| 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 420 | |> global_path | 
| 3987 | 421 | |> Theory.add_types | 
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 422 |    [("fun", 2, NoSyn),
 | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 423 |     ("prop", 0, NoSyn),
 | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 424 |     ("itself", 1, NoSyn),
 | 
| 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 425 |     ("dummy", 0, NoSyn)]
 | 
| 3987 | 426 | |> Theory.add_classes_i [(logicC, [])] | 
| 427 | |> Theory.add_defsort_i logicS | |
| 428 | |> Theory.add_arities_i | |
| 429 |    [("fun", [logicS, logicS], logicS),
 | |
| 430 |     ("prop", [], logicS),
 | |
| 431 |     ("itself", [logicS], logicS)]
 | |
| 4922 
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
 wenzelm parents: 
4853diff
changeset | 432 | |> Theory.add_nonterminals Syntax.pure_nonterms | 
| 3987 | 433 | |> Theory.add_syntax Syntax.pure_syntax | 
| 6692 | 434 | |> Theory.add_modesyntax (Symbol.symbolsN, true) Syntax.pure_sym_syntax | 
| 435 | |> Theory.add_modesyntax (Symbol.xsymbolsN, true) Syntax.pure_xsym_syntax | |
| 3987 | 436 | |> Theory.add_trfuns Syntax.pure_trfuns | 
| 437 | |> Theory.add_trfunsT Syntax.pure_trfunsT | |
| 438 | |> Theory.add_syntax | |
| 7949 | 439 |    [("==>", "[prop, prop] => prop", Delimfix "op ==>"),
 | 
| 440 | (dummy_patternN, "aprop", Delimfix "'_")] | |
| 3987 | 441 | |> Theory.add_consts | 
| 442 |    [("==", "['a::{}, 'a] => prop", InfixrName ("==", 2)),
 | |
| 443 |     ("=?=", "['a::{}, 'a] => prop", InfixrName ("=?=", 2)),
 | |
| 444 |     ("==>", "[prop, prop] => prop", Mixfix ("(_/ ==> _)", [2, 1], 1)),
 | |
| 445 |     ("all", "('a => prop) => prop", Binder ("!!", 0, 0)),
 | |
| 8039 | 446 |     ("Goal", "prop => prop", Mixfix ("GOAL _", [1000], 999)),
 | 
| 6547 | 447 |     ("TYPE", "'a itself", NoSyn),
 | 
| 6560 
1436349f8b28
renamed 'dummy' to 'dummy_pattern' (less dangerous);
 wenzelm parents: 
6547diff
changeset | 448 | (dummy_patternN, "'a", Delimfix "'_")] | 
| 5041 
a1d0a6d555cd
Goals may now contain assumptions, which are not returned.
 nipkow parents: 
5026diff
changeset | 449 |   |> Theory.add_modesyntax ("", false)
 | 
| 8039 | 450 |     [("Goal", "prop => prop", Mixfix ("_", [0], 0))]
 | 
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 451 | |> local_path | 
| 8419 
4770b1a12a93
add_thms, add_axioms, add_defs: return theorems as well;
 wenzelm parents: 
8039diff
changeset | 452 | |> (#1 oo (add_defs o map Thm.no_attributes)) | 
| 4788 | 453 |    [("flexpair_def", "(t =?= u) == (t == u::'a::{})"),
 | 
| 454 |     ("Goal_def", "GOAL (PROP A) == PROP A")]
 | |
| 4963 
38aa2d56e28c
added get_name, put_name, global_path, local_path, begin_theory,
 wenzelm parents: 
4933diff
changeset | 455 | |> end_theory; | 
| 3987 | 456 | |
| 5091 | 457 | structure ProtoPure = | 
| 458 | struct | |
| 459 | val thy = proto_pure; | |
| 460 | val flexpair_def = get_axiom thy "flexpair_def"; | |
| 461 | val Goal_def = get_axiom thy "Goal_def"; | |
| 462 | end; | |
| 3987 | 463 | |
| 464 | ||
| 465 | end; | |
| 466 | ||
| 467 | ||
| 4022 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 468 | structure BasicPureThy: BASIC_PURE_THY = PureThy; | 
| 
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
 wenzelm parents: 
4013diff
changeset | 469 | open BasicPureThy; |