| author | aspinall |
| Wed, 18 Jul 2007 14:46:59 +0200 | |
| changeset 23841 | 598839baafed |
| parent 23657 | 2332c79f4dc8 |
| child 23933 | e1a792312472 |
| permissions | -rw-r--r-- |
| 3987 | 1 |
(* Title: Pure/pure_thy.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
| 16441 | 5 |
Theorem storage. The ProtoPure theory. |
| 3987 | 6 |
*) |
7 |
||
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
8 |
signature BASIC_PURE_THY = |
|
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
9 |
sig |
| 16493 | 10 |
datatype interval = FromTo of int * int | From of int | Single of int |
| 18031 | 11 |
datatype thmref = |
12 |
Name of string | |
|
13 |
NameSelection of string * interval list | |
|
14 |
Fact of string |
|
|
15456
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
15 |
val get_thm: theory -> thmref -> thm |
|
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
16 |
val get_thms: theory -> thmref -> thm list |
|
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
17 |
val get_thmss: theory -> thmref list -> thm list |
| 5091 | 18 |
structure ProtoPure: |
19 |
sig |
|
20 |
val thy: theory |
|
| 18031 | 21 |
val prop_def: thm |
| 19775 | 22 |
val term_def: thm |
|
19125
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
23 |
val conjunction_def: thm |
| 5091 | 24 |
end |
| 4853 | 25 |
end; |
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
26 |
|
| 3987 | 27 |
signature PURE_THY = |
28 |
sig |
|
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
29 |
include BASIC_PURE_THY |
| 23657 | 30 |
val tag_rule: Markup.property -> thm -> thm |
| 18801 | 31 |
val untag_rule: string -> thm -> thm |
| 23657 | 32 |
val tag: Markup.property -> attribute |
| 18801 | 33 |
val untag: string -> attribute |
| 21964 | 34 |
val has_name_hint: thm -> bool |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
35 |
val get_name_hint: thm -> string |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
36 |
val put_name_hint: string -> thm -> thm |
| 22251 | 37 |
val has_kind: thm -> bool |
| 18801 | 38 |
val get_kind: thm -> string |
39 |
val kind_rule: string -> thm -> thm |
|
40 |
val kind: string -> attribute |
|
41 |
val kind_internal: attribute |
|
| 23657 | 42 |
val has_internal: Markup.property list -> bool |
| 18801 | 43 |
val is_internal: thm -> bool |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
44 |
val string_of_thmref: thmref -> string |
|
15456
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
45 |
val get_thm_closure: theory -> thmref -> thm |
|
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
46 |
val get_thms_closure: theory -> thmref -> thm list |
| 9564 | 47 |
val single_thm: string -> thm list -> thm |
| 16493 | 48 |
val name_of_thmref: thmref -> string |
49 |
val map_name_of_thmref: (string -> string) -> thmref -> thmref |
|
|
15456
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
50 |
val select_thm: thmref -> thm list -> thm list |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
51 |
val selections: string * thm list -> (thmref * thm) list |
| 17162 | 52 |
val theorems_of: theory -> thm list NameSpace.table |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
53 |
val fact_index_of: theory -> FactIndex.T |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
54 |
val valid_thms: theory -> thmref * thm list -> bool |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
55 |
val thms_containing: theory -> FactIndex.spec -> (string * thm list) list |
| 13646 | 56 |
val thms_containing_consts: theory -> string list -> (string * thm) list |
| 16336 | 57 |
val thms_of: theory -> (string * thm) list |
58 |
val all_thms_of: theory -> (string * thm) list |
|
| 12695 | 59 |
val hide_thms: bool -> string list -> theory -> theory |
| 21580 | 60 |
val map_facts: ('a -> 'b) -> ('c * ('a list * 'd) list) list -> ('c * ('b list * 'd) list) list
|
| 21567 | 61 |
val burrow_fact: ('a list -> 'b list) -> ('a list * 'c) list -> ('b list * 'c) list
|
| 21580 | 62 |
val burrow_facts: ('a list -> 'b list) ->
|
63 |
('c * ('a list * 'd) list) list -> ('c * ('b list * 'd) list) list
|
|
64 |
val name_multi: string -> 'a list -> (string * 'a) list |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
65 |
val name_thm: bool -> bool -> string -> thm -> thm |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
66 |
val name_thms: bool -> bool -> string -> thm list -> thm list |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
67 |
val name_thmss: bool -> string -> (thm list * 'a) list -> (thm list * 'a) list |
| 18728 | 68 |
val store_thm: (bstring * thm) * attribute list -> theory -> thm * theory |
| 7405 | 69 |
val smart_store_thms: (bstring * thm list) -> thm list |
|
12138
7cad58fbc866
renamed open_smart_store_thms to smart_store_thms_open;
wenzelm
parents:
12123
diff
changeset
|
70 |
val smart_store_thms_open: (bstring * thm list) -> thm list |
| 7899 | 71 |
val forall_elim_var: int -> thm -> thm |
72 |
val forall_elim_vars: int -> thm -> thm |
|
| 18728 | 73 |
val add_thms: ((bstring * thm) * attribute list) list -> theory -> thm list * theory |
74 |
val add_thmss: ((bstring * thm list) * attribute list) list -> theory -> thm list list * theory |
|
| 18801 | 75 |
val note_thmss: string -> ((bstring * attribute list) * |
| 18728 | 76 |
(thmref * attribute list) list) list -> theory -> (bstring * thm list) list * theory |
| 18801 | 77 |
val note_thmss_i: string -> ((bstring * attribute list) * |
78 |
(thm list * attribute list) list) list -> theory -> (bstring * thm list) list * theory |
|
79 |
val note_thmss_qualified: string -> string -> ((bstring * attribute list) * |
|
| 18728 | 80 |
(thm list * attribute list) list) list -> theory -> (bstring * thm list) list * theory |
81 |
val add_axioms: ((bstring * string) * attribute list) list -> theory -> thm list * theory |
|
82 |
val add_axioms_i: ((bstring * term) * attribute list) list -> theory -> thm list * theory |
|
83 |
val add_axiomss: ((bstring * string list) * attribute list) list -> |
|
84 |
theory -> thm list list * theory |
|
85 |
val add_axiomss_i: ((bstring * term list) * attribute list) list -> |
|
86 |
theory -> thm list list * theory |
|
87 |
val add_defs: bool -> ((bstring * string) * attribute list) list -> |
|
| 18377 | 88 |
theory -> thm list * theory |
| 18728 | 89 |
val add_defs_i: bool -> ((bstring * term) * attribute list) list -> |
| 18377 | 90 |
theory -> thm list * theory |
| 19629 | 91 |
val add_defs_unchecked: bool -> ((bstring * string) * attribute list) list -> |
92 |
theory -> thm list * theory |
|
93 |
val add_defs_unchecked_i: bool -> ((bstring * term) * attribute list) list -> |
|
94 |
theory -> thm list * theory |
|
| 18728 | 95 |
val add_defss: bool -> ((bstring * string list) * attribute list) list -> |
| 18377 | 96 |
theory -> thm list list * theory |
| 18728 | 97 |
val add_defss_i: bool -> ((bstring * term list) * attribute list) list -> |
| 18358 | 98 |
theory -> thm list list * theory |
| 3987 | 99 |
end; |
100 |
||
101 |
structure PureThy: PURE_THY = |
|
102 |
struct |
|
103 |
||
104 |
||
| 18801 | 105 |
(*** theorem tags ***) |
106 |
||
107 |
(* add / delete tags *) |
|
108 |
||
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
109 |
fun tag_rule tg = Thm.map_tags (insert (op =) tg); |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
110 |
fun untag_rule s = Thm.map_tags (filter_out (fn (s', _) => s = s')); |
| 18801 | 111 |
|
112 |
fun tag tg x = Thm.rule_attribute (K (tag_rule tg)) x; |
|
113 |
fun untag s x = Thm.rule_attribute (K (untag_rule s)) x; |
|
114 |
||
115 |
||
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
116 |
(* unofficial theorem names *) |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
117 |
|
| 23657 | 118 |
fun the_name_hint thm = the (AList.lookup (op =) (Thm.get_tags thm) Markup.nameN); |
| 22251 | 119 |
|
120 |
val has_name_hint = can the_name_hint; |
|
121 |
val get_name_hint = the_default "??.unknown" o try the_name_hint; |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
122 |
|
| 23657 | 123 |
fun put_name_hint name = untag_rule Markup.nameN #> tag_rule (Markup.nameN, name); |
| 21964 | 124 |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
125 |
|
| 18801 | 126 |
(* theorem kinds *) |
127 |
||
| 23657 | 128 |
fun the_kind thm = the (AList.lookup (op =) (Thm.get_tags thm) Markup.kindN); |
| 22251 | 129 |
|
130 |
val has_kind = can the_kind; |
|
131 |
val get_kind = the_default "??.unknown" o try the_kind; |
|
| 18801 | 132 |
|
| 23657 | 133 |
fun kind_rule k = tag_rule (Markup.kindN, k) o untag_rule Markup.kindN; |
| 18801 | 134 |
fun kind k x = if k = "" then x else Thm.rule_attribute (K (kind_rule k)) x; |
| 22363 | 135 |
fun kind_internal x = kind Thm.internalK x; |
| 23657 | 136 |
fun has_internal tags = exists (fn tg => tg = (Markup.kindN, Thm.internalK)) tags; |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
137 |
val is_internal = has_internal o Thm.get_tags; |
| 18801 | 138 |
|
139 |
||
140 |
||
|
4922
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
wenzelm
parents:
4853
diff
changeset
|
141 |
(*** theorem database ***) |
| 3987 | 142 |
|
| 16441 | 143 |
(** dataype theorems **) |
| 3987 | 144 |
|
| 16441 | 145 |
structure TheoremsData = TheoryDataFun |
146 |
(struct |
|
| 5005 | 147 |
type T = |
| 16441 | 148 |
{theorems: thm list NameSpace.table,
|
149 |
index: FactIndex.T} ref; |
|
| 3987 | 150 |
|
| 4853 | 151 |
fun mk_empty _ = |
| 16336 | 152 |
ref {theorems = NameSpace.empty_table, index = FactIndex.empty}: T;
|
| 3987 | 153 |
|
| 5005 | 154 |
val empty = mk_empty (); |
| 6547 | 155 |
fun copy (ref x) = ref x; |
| 16441 | 156 |
val extend = mk_empty; |
157 |
fun merge _ = mk_empty; |
|
|
19426
b9289b560446
moved print_theorems/theory to Isar/proof_display.ML;
wenzelm
parents:
19391
diff
changeset
|
158 |
fun print _ _ = (); |
| 16441 | 159 |
end); |
| 3987 | 160 |
|
| 16493 | 161 |
val get_theorems_ref = TheoremsData.get; |
162 |
val get_theorems = ! o get_theorems_ref; |
|
| 17162 | 163 |
val theorems_of = #theorems o get_theorems; |
| 16493 | 164 |
val fact_index_of = #index o get_theorems; |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
165 |
|
| 6367 | 166 |
|
| 3987 | 167 |
|
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
168 |
(** retrieve theorems **) |
| 3987 | 169 |
|
| 15531 | 170 |
fun the_thms _ (SOME thms) = thms |
171 |
| the_thms name NONE = error ("Unknown theorem(s) " ^ quote name);
|
|
| 4037 | 172 |
|
| 9564 | 173 |
fun single_thm _ [thm] = thm |
174 |
| single_thm name _ = error ("Single theorem expected " ^ quote name);
|
|
175 |
||
| 15703 | 176 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
177 |
(* datatype interval *) |
| 15703 | 178 |
|
179 |
datatype interval = |
|
180 |
FromTo of int * int | |
|
181 |
From of int | |
|
182 |
Single of int; |
|
183 |
||
184 |
fun interval _ (FromTo (i, j)) = i upto j |
|
185 |
| interval n (From i) = i upto n |
|
186 |
| interval _ (Single i) = [i]; |
|
187 |
||
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
188 |
fun string_of_interval (FromTo (i, j)) = string_of_int i ^ "-" ^ string_of_int j |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
189 |
| string_of_interval (From i) = string_of_int i ^ "-" |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
190 |
| string_of_interval (Single i) = string_of_int i; |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
191 |
|
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
192 |
|
| 16493 | 193 |
(* datatype thmref *) |
194 |
||
195 |
datatype thmref = |
|
196 |
Name of string | |
|
| 18031 | 197 |
NameSelection of string * interval list | |
198 |
Fact of string; |
|
| 15703 | 199 |
|
| 16493 | 200 |
fun name_of_thmref (Name name) = name |
| 18031 | 201 |
| name_of_thmref (NameSelection (name, _)) = name |
| 18678 | 202 |
| name_of_thmref (Fact _) = error "Illegal literal fact"; |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
203 |
|
| 16493 | 204 |
fun map_name_of_thmref f (Name name) = Name (f name) |
| 18031 | 205 |
| map_name_of_thmref f (NameSelection (name, is)) = NameSelection (f name, is) |
206 |
| map_name_of_thmref _ thmref = thmref; |
|
| 16493 | 207 |
|
208 |
fun string_of_thmref (Name name) = name |
|
209 |
| string_of_thmref (NameSelection (name, is)) = |
|
| 18031 | 210 |
name ^ enclose "(" ")" (commas (map string_of_interval is))
|
| 18678 | 211 |
| string_of_thmref (Fact _) = error "Illegal literal fact"; |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
212 |
|
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
213 |
|
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
214 |
(* select_thm *) |
| 15703 | 215 |
|
| 16493 | 216 |
fun select_thm (Name _) thms = thms |
| 18031 | 217 |
| select_thm (Fact _) thms = thms |
| 16493 | 218 |
| select_thm (NameSelection (name, is)) thms = |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
219 |
let |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
220 |
val n = length thms; |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
221 |
fun select i = |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
222 |
if i < 1 orelse i > n then |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
223 |
error ("Bad subscript " ^ string_of_int i ^ " for " ^
|
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
224 |
quote name ^ " (length " ^ string_of_int n ^ ")") |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
225 |
else List.nth (thms, i - 1); |
|
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19473
diff
changeset
|
226 |
in map select (maps (interval n) is) end; |
| 15703 | 227 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
228 |
|
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
229 |
(* selections *) |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
230 |
|
| 16493 | 231 |
fun selections (name, [thm]) = [(Name name, thm)] |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
232 |
| selections (name, thms) = (1 upto length thms, thms) |> ListPair.map (fn (i, thm) => |
| 16493 | 233 |
(NameSelection (name, [Single i]), thm)); |
|
15456
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
234 |
|
| 9564 | 235 |
|
| 9808 | 236 |
(* get_thm(s)_closure -- statically scoped versions *) |
| 9564 | 237 |
|
238 |
(*beware of proper order of evaluation!*) |
|
|
4922
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
wenzelm
parents:
4853
diff
changeset
|
239 |
|
| 9564 | 240 |
fun lookup_thms thy = |
241 |
let |
|
| 16441 | 242 |
val thy_ref = Theory.self_ref thy; |
| 16493 | 243 |
val (space, thms) = #theorems (get_theorems thy); |
| 9564 | 244 |
in |
245 |
fn name => |
|
| 17221 | 246 |
Option.map (map (Thm.transfer (Theory.deref thy_ref))) (*dynamic identity*) |
| 17418 | 247 |
(Symtab.lookup thms (NameSpace.intern space name)) (*static content*) |
| 9564 | 248 |
end; |
| 3987 | 249 |
|
| 9564 | 250 |
fun get_thms_closure thy = |
| 16441 | 251 |
let val closures = map lookup_thms (thy :: Theory.ancestors_of thy) in |
| 16493 | 252 |
fn thmref => |
| 18031 | 253 |
let val name = name_of_thmref thmref; |
| 16493 | 254 |
in select_thm thmref (the_thms name (get_first (fn f => f name) closures)) end |
|
15456
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
berghofe
parents:
15387
diff
changeset
|
255 |
end; |
| 9564 | 256 |
|
| 9808 | 257 |
fun get_thm_closure thy = |
258 |
let val get = get_thms_closure thy |
|
| 16493 | 259 |
in fn thmref => single_thm (name_of_thmref thmref) (get thmref) end; |
| 9808 | 260 |
|
| 9564 | 261 |
|
| 16441 | 262 |
(* get_thms etc. *) |
| 9564 | 263 |
|
| 16493 | 264 |
fun get_thms theory thmref = |
265 |
let val name = name_of_thmref thmref in |
|
266 |
get_first (fn thy => lookup_thms thy name) (theory :: Theory.ancestors_of theory) |
|
267 |
|> the_thms name |> select_thm thmref |> map (Thm.transfer theory) |
|
268 |
end; |
|
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
269 |
|
|
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19473
diff
changeset
|
270 |
fun get_thmss thy thmrefs = maps (get_thms thy) thmrefs; |
| 16493 | 271 |
fun get_thm thy thmref = single_thm (name_of_thmref thmref) (get_thms thy thmref); |
| 4783 | 272 |
|
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
273 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
274 |
(* thms_containing etc. *) |
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
275 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
276 |
fun valid_thms thy (thmref, ths) = |
| 18678 | 277 |
(case try (get_thms thy) thmref of |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
278 |
NONE => false |
| 16132 | 279 |
| SOME ths' => Thm.eq_thms (ths, ths')); |
| 3987 | 280 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
281 |
fun thms_containing theory spec = |
|
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
282 |
(theory :: Theory.ancestors_of theory) |
|
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19473
diff
changeset
|
283 |
|> maps (fn thy => |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
284 |
FactIndex.find (fact_index_of thy) spec |
| 16493 | 285 |
|> List.filter (fn (name, ths) => valid_thms theory (Name name, ths)) |
|
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19473
diff
changeset
|
286 |
|> distinct (eq_fst (op =))); |
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
287 |
|
| 13646 | 288 |
fun thms_containing_consts thy consts = |
|
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19473
diff
changeset
|
289 |
thms_containing thy (consts, []) |> maps #2 |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
290 |
|> map (`(get_name_hint)); |
| 13646 | 291 |
|
|
15882
a191d2bee3e1
new thms_containing that searches for patterns instead of constants
kleing
parents:
15801
diff
changeset
|
292 |
|
| 16336 | 293 |
(* thms_of etc. *) |
|
15882
a191d2bee3e1
new thms_containing that searches for patterns instead of constants
kleing
parents:
15801
diff
changeset
|
294 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
295 |
fun thms_of thy = |
| 17162 | 296 |
let val thms = #2 (theorems_of thy) |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
297 |
in map (`(get_name_hint)) (maps snd (Symtab.dest thms)) end; |
| 15703 | 298 |
|
|
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19473
diff
changeset
|
299 |
fun all_thms_of thy = maps thms_of (thy :: Theory.ancestors_of thy); |
| 16336 | 300 |
|
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
301 |
|
|
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
302 |
|
|
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
303 |
(** store theorems **) (*DESTRUCTIVE*) |
| 3987 | 304 |
|
| 16441 | 305 |
(* hiding -- affects current theory node only *) |
| 12695 | 306 |
|
| 13424 | 307 |
fun hide_thms fully names thy = |
| 12695 | 308 |
let |
| 16493 | 309 |
val r as ref {theorems = (space, thms), index} = get_theorems_ref thy;
|
| 16132 | 310 |
val space' = fold (NameSpace.hide fully) names space; |
| 16336 | 311 |
in r := {theorems = (space', thms), index = index}; thy end;
|
| 12695 | 312 |
|
313 |
||
| 21580 | 314 |
(* fact specifications *) |
315 |
||
316 |
fun map_facts f = map (apsnd (map (apfst (map f)))); |
|
317 |
fun burrow_fact f = split_list #>> burrow f #> op ~~; |
|
318 |
fun burrow_facts f = split_list ##> burrow (burrow_fact f) #> op ~~; |
|
319 |
||
320 |
||
| 4853 | 321 |
(* naming *) |
322 |
||
| 18614 | 323 |
fun gen_names _ len "" = replicate len "" |
324 |
| gen_names j len name = map (fn i => name ^ "_" ^ string_of_int i) (j + 1 upto j + len); |
|
| 4853 | 325 |
|
| 18801 | 326 |
fun name_multi name [x] = [(name, x)] |
327 |
| name_multi name xs = gen_names 0 (length xs) name ~~ xs; |
|
|
12235
5fa04fc9b254
Further restructuring of theorem naming functions.
berghofe
parents:
12138
diff
changeset
|
328 |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
329 |
fun name_thm pre official name thm = thm |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
330 |
|> (if Thm.get_name thm <> "" andalso pre orelse not official then I else Thm.put_name name) |
| 21964 | 331 |
|> (if has_name_hint thm andalso pre orelse name = "" then I else put_name_hint name); |
|
12872
0855c3ab2047
Theorems are only "pre-named" if the do not already have names.
berghofe
parents:
12711
diff
changeset
|
332 |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
333 |
fun name_thms pre official name xs = |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
334 |
map (uncurry (name_thm pre official)) (name_multi name xs); |
|
12235
5fa04fc9b254
Further restructuring of theorem naming functions.
berghofe
parents:
12138
diff
changeset
|
335 |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
336 |
fun name_thmss official name fact = |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
337 |
burrow_fact (name_thms true official name) fact; |
| 4853 | 338 |
|
339 |
||
| 11998 | 340 |
(* enter_thms *) |
| 4853 | 341 |
|
|
7470
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
wenzelm
parents:
7405
diff
changeset
|
342 |
fun warn_overwrite name = warning ("Replaced old copy of theorems " ^ quote name);
|
|
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
wenzelm
parents:
7405
diff
changeset
|
343 |
fun warn_same name = warning ("Theorem database already contains a copy of " ^ quote name);
|
| 3987 | 344 |
|
|
18418
bf448d999b7e
re-arranged tuples (theory * 'a) to ('a * theory) in Pure
haftmann
parents:
18377
diff
changeset
|
345 |
fun enter_thms _ _ app_att ("", thms) thy = app_att (thy, thms) |> swap
|
| 16441 | 346 |
| enter_thms pre_name post_name app_att (bname, thms) thy = |
|
7470
9f67ca1e03dc
eliminated default_name (thms no longer stored for name "");
wenzelm
parents:
7405
diff
changeset
|
347 |
let |
| 16441 | 348 |
val name = Sign.full_name thy bname; |
349 |
val (thy', thms') = apsnd (post_name name) (app_att (thy, pre_name name thms)); |
|
|
16513
f38693aad717
enter_thms: use theorem database of thy *after* attribute application;
wenzelm
parents:
16493
diff
changeset
|
350 |
val r as ref {theorems = (space, theorems), index} = get_theorems_ref thy';
|
|
f38693aad717
enter_thms: use theorem database of thy *after* attribute application;
wenzelm
parents:
16493
diff
changeset
|
351 |
val space' = Sign.declare_name thy' name space; |
| 17418 | 352 |
val theorems' = Symtab.update (name, thms') theorems; |
| 18031 | 353 |
val index' = FactIndex.add_global (name, thms') index; |
| 13274 | 354 |
in |
| 17418 | 355 |
(case Symtab.lookup theorems name of |
| 15531 | 356 |
NONE => () |
| 16441 | 357 |
| SOME thms'' => |
358 |
if Thm.eq_thms (thms', thms'') then warn_same name |
|
| 13274 | 359 |
else warn_overwrite name); |
| 16336 | 360 |
r := {theorems = (space', theorems'), index = index'};
|
|
18418
bf448d999b7e
re-arranged tuples (theory * 'a) to ('a * theory) in Pure
haftmann
parents:
18377
diff
changeset
|
361 |
(thms', thy') |
| 11998 | 362 |
end; |
| 3987 | 363 |
|
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
364 |
|
| 6091 | 365 |
(* add_thms(s) *) |
| 4853 | 366 |
|
| 16441 | 367 |
fun add_thms_atts pre_name ((bname, thms), atts) = |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
368 |
enter_thms pre_name (name_thms false true) |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
369 |
(foldl_map (Thm.theory_attributes atts)) (bname, thms); |
| 4853 | 370 |
|
| 18377 | 371 |
fun gen_add_thmss pre_name = |
372 |
fold_map (add_thms_atts pre_name); |
|
| 5907 | 373 |
|
|
12235
5fa04fc9b254
Further restructuring of theorem naming functions.
berghofe
parents:
12138
diff
changeset
|
374 |
fun gen_add_thms pre_name args = |
| 18377 | 375 |
apfst (map hd) o gen_add_thmss pre_name (map (apfst (apsnd single)) args); |
|
12235
5fa04fc9b254
Further restructuring of theorem naming functions.
berghofe
parents:
12138
diff
changeset
|
376 |
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
377 |
val add_thmss = gen_add_thmss (name_thms true true); |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
378 |
val add_thms = gen_add_thms (name_thms true true); |
| 5907 | 379 |
|
380 |
||
| 14564 | 381 |
(* note_thmss(_i) *) |
| 5907 | 382 |
|
| 9192 | 383 |
local |
| 12711 | 384 |
|
| 18801 | 385 |
fun gen_note_thmss get k = fold_map (fn ((bname, more_atts), ths_atts) => fn thy => |
| 12711 | 386 |
let |
| 18728 | 387 |
fun app (x, (ths, atts)) = foldl_map (Thm.theory_attributes atts) (x, ths); |
|
18418
bf448d999b7e
re-arranged tuples (theory * 'a) to ('a * theory) in Pure
haftmann
parents:
18377
diff
changeset
|
388 |
val (thms, thy') = thy |> enter_thms |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
389 |
(name_thmss true) (name_thms false true) (apsnd flat o foldl_map app) |
| 18801 | 390 |
(bname, map (fn (ths, atts) => (get thy ths, atts @ more_atts @ [kind k])) ths_atts); |
391 |
in ((bname, thms), thy') end); |
|
| 12711 | 392 |
|
| 9192 | 393 |
in |
| 12711 | 394 |
|
|
18418
bf448d999b7e
re-arranged tuples (theory * 'a) to ('a * theory) in Pure
haftmann
parents:
18377
diff
changeset
|
395 |
val note_thmss = gen_note_thmss get_thms; |
|
bf448d999b7e
re-arranged tuples (theory * 'a) to ('a * theory) in Pure
haftmann
parents:
18377
diff
changeset
|
396 |
val note_thmss_i = gen_note_thmss (K I); |
| 12711 | 397 |
|
| 21438 | 398 |
end; |
399 |
||
| 18801 | 400 |
fun note_thmss_qualified k path facts thy = |
401 |
thy |
|
| 22796 | 402 |
|> Sign.add_path path |
403 |
|> Sign.no_base_names |
|
| 18801 | 404 |
|> note_thmss_i k facts |
| 22796 | 405 |
||> Sign.restore_naming thy; |
| 18801 | 406 |
|
| 5280 | 407 |
|
| 6091 | 408 |
(* store_thm *) |
| 5280 | 409 |
|
| 11998 | 410 |
fun store_thm ((bname, thm), atts) thy = |
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
411 |
let val ([th'], thy') = add_thms_atts (name_thms true true) ((bname, [thm]), atts) thy |
| 18358 | 412 |
in (th', thy') end; |
| 3987 | 413 |
|
414 |
||
| 16441 | 415 |
(* smart_store_thms(_open) *) |
| 3987 | 416 |
|
| 16441 | 417 |
local |
418 |
||
419 |
fun smart_store _ (name, []) = |
|
|
11516
a0633bdcd015
Added equality axioms and initialization of proof term package.
berghofe
parents:
10667
diff
changeset
|
420 |
error ("Cannot store empty list of theorems: " ^ quote name)
|
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
421 |
| smart_store official (name, [thm]) = |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
422 |
fst (enter_thms (name_thms true official) (name_thms false official) I (name, [thm]) |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
423 |
(Thm.theory_of_thm thm)) |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
424 |
| smart_store official (name, thms) = |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
425 |
let val thy = Theory.merge_list (map Thm.theory_of_thm thms) in |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
426 |
fst (enter_thms (name_thms true official) (name_thms false official) I (name, thms) thy) |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
427 |
end; |
|
11516
a0633bdcd015
Added equality axioms and initialization of proof term package.
berghofe
parents:
10667
diff
changeset
|
428 |
|
| 16441 | 429 |
in |
430 |
||
|
21646
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
431 |
val smart_store_thms = smart_store true; |
|
c07b5b0e8492
thm/prf: separate official name vs. additional tags;
wenzelm
parents:
21606
diff
changeset
|
432 |
val smart_store_thms_open = smart_store false; |
| 16441 | 433 |
|
434 |
end; |
|
| 3987 | 435 |
|
436 |
||
|
16722
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
437 |
(* forall_elim_var(s) -- belongs to drule.ML *) |
| 7899 | 438 |
|
|
16722
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
439 |
fun forall_elim_vars_aux strip_vars i th = |
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
440 |
let |
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
441 |
val {thy, tpairs, prop, ...} = Thm.rep_thm th;
|
| 16787 | 442 |
val add_used = Term.fold_aterms |
| 20853 | 443 |
(fn Var ((x, j), _) => if i = j then insert (op =) x else I | _ => I); |
|
16722
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
444 |
val used = fold (fn (t, u) => add_used t o add_used u) tpairs (add_used prop []); |
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
445 |
val vars = strip_vars prop; |
|
20071
8f3e1ddb50e6
replaced Term.variant(list) by Name.variant(_list);
wenzelm
parents:
20057
diff
changeset
|
446 |
val cvars = (Name.variant_list used (map #1 vars), vars) |
|
16722
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
447 |
|> ListPair.map (fn (x, (_, T)) => Thm.cterm_of thy (Var ((x, i), T))); |
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
448 |
in fold Thm.forall_elim cvars th end; |
| 7899 | 449 |
|
|
16722
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
450 |
val forall_elim_vars = forall_elim_vars_aux Term.strip_all_vars; |
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
451 |
|
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
452 |
fun forall_elim_var i th = forall_elim_vars_aux |
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
453 |
(fn Const ("all", _) $ Abs (a, T, _) => [(a, T)]
|
|
040728f6a103
tuned forall_elim_var(s): avoid expensive Term.add_vars;
wenzelm
parents:
16536
diff
changeset
|
454 |
| _ => raise THM ("forall_elim_vars", i, [th])) i th;
|
| 7899 | 455 |
|
456 |
||
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
457 |
(* store axioms as theorems *) |
|
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
458 |
|
| 4853 | 459 |
local |
| 17418 | 460 |
fun get_ax thy (name, _) = Thm.get_axiom_i thy (Sign.full_name thy name); |
461 |
fun get_axs thy named_axs = map (forall_elim_vars 0 o get_ax thy) named_axs; |
|
| 18377 | 462 |
fun add_single add ((name, ax), atts) thy = |
| 4853 | 463 |
let |
| 11998 | 464 |
val named_ax = [(name, ax)]; |
| 7753 | 465 |
val thy' = add named_ax thy; |
466 |
val thm = hd (get_axs thy' named_ax); |
|
| 18377 | 467 |
in apfst hd (gen_add_thms (K I) [((name, thm), atts)] thy') end; |
468 |
fun add_multi add ((name, axs), atts) thy = |
|
| 7753 | 469 |
let |
470 |
val named_axs = name_multi name axs; |
|
| 4853 | 471 |
val thy' = add named_axs thy; |
| 7753 | 472 |
val thms = get_axs thy' named_axs; |
| 18377 | 473 |
in apfst hd (gen_add_thmss (K I) [((name, thms), atts)] thy') end; |
474 |
fun add_singles add = fold_map (add_single add); |
|
475 |
fun add_multis add = fold_map (add_multi add); |
|
| 4853 | 476 |
in |
| 19629 | 477 |
val add_axioms = add_singles Theory.add_axioms; |
478 |
val add_axioms_i = add_singles Theory.add_axioms_i; |
|
479 |
val add_axiomss = add_multis Theory.add_axioms; |
|
480 |
val add_axiomss_i = add_multis Theory.add_axioms_i; |
|
| 22796 | 481 |
val add_defs = add_singles o Theory.add_defs false; |
482 |
val add_defs_i = add_singles o Theory.add_defs_i false; |
|
483 |
val add_defs_unchecked = add_singles o Theory.add_defs true; |
|
484 |
val add_defs_unchecked_i = add_singles o Theory.add_defs_i true; |
|
485 |
val add_defss = add_multis o Theory.add_defs false; |
|
486 |
val add_defss_i = add_multis o Theory.add_defs_i false; |
|
| 4853 | 487 |
end; |
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
488 |
|
|
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
489 |
|
| 3987 | 490 |
|
| 5091 | 491 |
(*** the ProtoPure theory ***) |
| 3987 | 492 |
|
| 16441 | 493 |
val aT = TFree ("'a", []);
|
494 |
val A = Free ("A", propT);
|
|
495 |
||
| 3987 | 496 |
val proto_pure = |
| 16493 | 497 |
Context.pre_pure_thy |
| 16987 | 498 |
|> Compress.init_data |
|
16023
66561f6814bd
added string_of_thmref, selections, fact_index_of, valid_thms;
wenzelm
parents:
15975
diff
changeset
|
499 |
|> TheoremsData.init |
| 22796 | 500 |
|> Sign.add_types |
|
4922
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
wenzelm
parents:
4853
diff
changeset
|
501 |
[("fun", 2, NoSyn),
|
|
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
wenzelm
parents:
4853
diff
changeset
|
502 |
("prop", 0, NoSyn),
|
|
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
wenzelm
parents:
4853
diff
changeset
|
503 |
("itself", 1, NoSyn),
|
|
03b81b6e1baa
added thms_closure: theory -> xstring -> tthm list option;
wenzelm
parents:
4853
diff
changeset
|
504 |
("dummy", 0, NoSyn)]
|
| 22796 | 505 |
|> Sign.add_nonterminals Syntax.basic_nonterms |
506 |
|> Sign.add_syntax |
|
| 18713 | 507 |
[("_lambda", "[pttrns, 'a] => logic", Mixfix ("(3%_./ _)", [0, 3], 3)),
|
508 |
("_abs", "'a", NoSyn),
|
|
509 |
("", "'a => args", Delimfix "_"),
|
|
510 |
("_args", "['a, args] => args", Delimfix "_,/ _"),
|
|
511 |
("", "id => idt", Delimfix "_"),
|
|
512 |
("_idtdummy", "idt", Delimfix "'_"),
|
|
513 |
("_idtyp", "[id, type] => idt", Mixfix ("_::_", [], 0)),
|
|
514 |
("_idtypdummy", "type => idt", Mixfix ("'_()::_", [], 0)),
|
|
515 |
("", "idt => idt", Delimfix "'(_')"),
|
|
516 |
("", "idt => idts", Delimfix "_"),
|
|
517 |
("_idts", "[idt, idts] => idts", Mixfix ("_/ _", [1, 0], 0)),
|
|
518 |
("", "idt => pttrn", Delimfix "_"),
|
|
519 |
("", "pttrn => pttrns", Delimfix "_"),
|
|
520 |
("_pttrns", "[pttrn, pttrns] => pttrns", Mixfix ("_/ _", [1, 0], 0)),
|
|
521 |
("", "id => aprop", Delimfix "_"),
|
|
522 |
("", "longid => aprop", Delimfix "_"),
|
|
523 |
("", "var => aprop", Delimfix "_"),
|
|
524 |
("_DDDOT", "aprop", Delimfix "..."),
|
|
525 |
("_aprop", "aprop => prop", Delimfix "PROP _"),
|
|
526 |
("_asm", "prop => asms", Delimfix "_"),
|
|
527 |
("_asms", "[prop, asms] => asms", Delimfix "_;/ _"),
|
|
528 |
("_bigimpl", "[asms, prop] => prop", Mixfix ("((3[| _ |])/ ==> _)", [0, 1], 1)),
|
|
529 |
("_ofclass", "[type, logic] => prop", Delimfix "(1OFCLASS/(1'(_,/ _')))"),
|
|
530 |
("_mk_ofclass", "_", NoSyn),
|
|
531 |
("_TYPE", "type => logic", Delimfix "(1TYPE/(1'(_')))"),
|
|
532 |
("", "id => logic", Delimfix "_"),
|
|
533 |
("", "longid => logic", Delimfix "_"),
|
|
534 |
("", "var => logic", Delimfix "_"),
|
|
535 |
("_DDDOT", "logic", Delimfix "..."),
|
|
536 |
("_constify", "num => num_const", Delimfix "_"),
|
|
537 |
("_indexnum", "num_const => index", Delimfix "\\<^sub>_"),
|
|
538 |
("_index", "logic => index", Delimfix "(00\\<^bsub>_\\<^esub>)"),
|
|
539 |
("_indexdefault", "index", Delimfix ""),
|
|
540 |
("_indexvar", "index", Delimfix "'\\<index>"),
|
|
541 |
("_struct", "index => logic", Mixfix ("\\<struct>_", [1000], 1000)),
|
|
542 |
("==>", "prop => prop => prop", Delimfix "op ==>"),
|
|
543 |
(Term.dummy_patternN, "aprop", Delimfix "'_")] |
|
| 22796 | 544 |
|> Sign.add_syntax Syntax.appl_syntax |
545 |
|> Sign.add_modesyntax (Symbol.xsymbolsN, true) |
|
| 18713 | 546 |
[("fun", "[type, type] => type", Mixfix ("(_/ \\<Rightarrow> _)", [1, 0], 0)),
|
547 |
("_bracket", "[types, type] => type", Mixfix ("([_]/ \\<Rightarrow> _)", [0, 0], 0)),
|
|
548 |
("_ofsort", "[tid, sort] => type", Mixfix ("_\\<Colon>_", [1000, 0], 1000)),
|
|
549 |
("_constrain", "['a, type] => 'a", Mixfix ("_\\<Colon>_", [4, 0], 3)),
|
|
| 21524 | 550 |
("_idtyp", "[id, type] => idt", Mixfix ("_\\<Colon>_", [], 0)),
|
| 18713 | 551 |
("_idtypdummy", "type => idt", Mixfix ("'_()\\<Colon>_", [], 0)),
|
| 19577 | 552 |
("_type_constraint_", "'a", NoSyn),
|
| 18713 | 553 |
("_lambda", "[pttrns, 'a] => logic", Mixfix ("(3\\<lambda>_./ _)", [0, 3], 3)),
|
554 |
("==", "['a, 'a] => prop", InfixrName ("\\<equiv>", 2)),
|
|
| 21524 | 555 |
("all_binder", "[idts, prop] => prop", Mixfix ("(3\\<And>_./ _)", [0, 0], 0)),
|
| 18713 | 556 |
("==>", "[prop, prop] => prop", InfixrName ("\\<Longrightarrow>", 1)),
|
557 |
("_DDDOT", "aprop", Delimfix "\\<dots>"),
|
|
558 |
("_bigimpl", "[asms, prop] => prop", Mixfix ("((1\\<lbrakk>_\\<rbrakk>)/ \\<Longrightarrow> _)", [0, 1], 1)),
|
|
559 |
("_DDDOT", "logic", Delimfix "\\<dots>")]
|
|
| 22796 | 560 |
|> Sign.add_modesyntax ("", false)
|
| 18713 | 561 |
[("prop", "prop => prop", Mixfix ("_", [0], 0)),
|
| 19775 | 562 |
("ProtoPure.term", "'a => prop", Delimfix "TERM _"),
|
|
19125
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
563 |
("ProtoPure.conjunction", "prop => prop => prop", InfixrName ("&&", 2))]
|
| 22796 | 564 |
|> Sign.add_modesyntax ("HTML", false)
|
| 18713 | 565 |
[("_lambda", "[pttrns, 'a] => logic", Mixfix ("(3\\<lambda>_./ _)", [0, 3], 3))]
|
| 22796 | 566 |
|> Sign.add_consts |
| 16441 | 567 |
[("==", "'a => 'a => prop", InfixrName ("==", 2)),
|
568 |
("==>", "prop => prop => prop", Mixfix ("(_/ ==> _)", [2, 1], 1)),
|
|
| 3987 | 569 |
("all", "('a => prop) => prop", Binder ("!!", 0, 0)),
|
| 18031 | 570 |
("prop", "prop => prop", NoSyn),
|
| 6547 | 571 |
("TYPE", "'a itself", NoSyn),
|
| 9534 | 572 |
(Term.dummy_patternN, "'a", Delimfix "'_")] |
|
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13800
diff
changeset
|
573 |
|> Theory.add_finals_i false |
| 16441 | 574 |
[Const ("==", [aT, aT] ---> propT),
|
575 |
Const ("==>", [propT, propT] ---> propT),
|
|
576 |
Const ("all", (aT --> propT) --> propT),
|
|
| 19391 | 577 |
Const ("TYPE", Term.a_itselfT),
|
| 17703 | 578 |
Const (Term.dummy_patternN, aT)] |
| 22796 | 579 |
|> Sign.add_trfuns Syntax.pure_trfuns |
580 |
|> Sign.add_trfunsT Syntax.pure_trfunsT |
|
| 16441 | 581 |
|> Sign.local_path |
| 22796 | 582 |
|> Sign.add_consts |
| 19775 | 583 |
[("term", "'a => prop", NoSyn),
|
584 |
("conjunction", "prop => prop => prop", NoSyn)]
|
|
|
19125
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
585 |
|> (add_defs false o map Thm.no_attributes) |
|
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
586 |
[("prop_def", "prop(A) == A"),
|
| 19775 | 587 |
("term_def", "term(x) == (!!A. PROP A ==> PROP A)"),
|
|
19125
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
588 |
("conjunction_def",
|
|
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
589 |
"conjunction(A, B) == (!!C. (PROP A ==> PROP B ==> PROP C) ==> PROP C)")] |> snd |
| 19775 | 590 |
|> Sign.hide_consts false ["conjunction", "term"] |
| 18377 | 591 |
|> add_thmss [(("nothing", []), [])] |> snd
|
|
11516
a0633bdcd015
Added equality axioms and initialization of proof term package.
berghofe
parents:
10667
diff
changeset
|
592 |
|> Theory.add_axioms_i Proofterm.equality_axms |
| 16493 | 593 |
|> Theory.end_theory; |
| 3987 | 594 |
|
| 5091 | 595 |
structure ProtoPure = |
596 |
struct |
|
597 |
val thy = proto_pure; |
|
| 18031 | 598 |
val prop_def = get_axiom thy "prop_def"; |
| 19775 | 599 |
val term_def = get_axiom thy "term_def"; |
|
19125
59b26248547b
simplified Pure conjunction, based on actual const;
wenzelm
parents:
19046
diff
changeset
|
600 |
val conjunction_def = get_axiom thy "conjunction_def"; |
| 5091 | 601 |
end; |
| 3987 | 602 |
|
603 |
end; |
|
604 |
||
|
4022
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
605 |
structure BasicPureThy: BASIC_PURE_THY = PureThy; |
|
0770a19c48d3
added ignored_consts, thms_containing, add_store_axioms(_i),
wenzelm
parents:
4013
diff
changeset
|
606 |
open BasicPureThy; |