50 val store_thm: (bstring * thm) * theory attribute list -> theory -> thm * theory |
50 val store_thm: (bstring * thm) * theory attribute list -> theory -> thm * theory |
51 val smart_store_thms: (bstring * thm list) -> thm list |
51 val smart_store_thms: (bstring * thm list) -> thm list |
52 val smart_store_thms_open: (bstring * thm list) -> thm list |
52 val smart_store_thms_open: (bstring * thm list) -> thm list |
53 val forall_elim_var: int -> thm -> thm |
53 val forall_elim_var: int -> thm -> thm |
54 val forall_elim_vars: int -> thm -> thm |
54 val forall_elim_vars: int -> thm -> thm |
55 val add_thms: ((bstring * thm) * theory attribute list) list -> theory -> theory * thm list |
55 val add_thms: ((bstring * thm) * theory attribute list) list -> theory -> thm list * theory |
56 val add_thmss: ((bstring * thm list) * theory attribute list) list -> theory |
56 val add_thmss: ((bstring * thm list) * theory attribute list) list -> theory |
57 -> theory * thm list list |
57 -> thm list list * theory |
58 val note_thmss: theory attribute -> ((bstring * theory attribute list) * |
58 val note_thmss: theory attribute -> ((bstring * theory attribute list) * |
59 (thmref * theory attribute list) list) list -> |
59 (thmref * theory attribute list) list) list -> |
60 theory -> theory * (bstring * thm list) list |
60 theory -> (bstring * thm list) list * theory |
61 val note_thmss_i: theory attribute -> ((bstring * theory attribute list) * |
61 val note_thmss_i: theory attribute -> ((bstring * theory attribute list) * |
62 (thm list * theory attribute list) list) list -> |
62 (thm list * theory attribute list) list) list -> |
63 theory -> theory * (bstring * thm list) list |
63 theory -> (bstring * thm list) list * theory |
64 val add_axioms: ((bstring * string) * theory attribute list) list -> |
64 val add_axioms: ((bstring * string) * theory attribute list) list -> |
65 theory -> theory * thm list |
65 theory -> thm list * theory |
66 val add_axioms_i: ((bstring * term) * theory attribute list) list -> |
66 val add_axioms_i: ((bstring * term) * theory attribute list) list -> |
67 theory -> theory * thm list |
67 theory -> thm list * theory |
68 val add_axiomss: ((bstring * string list) * theory attribute list) list -> |
68 val add_axiomss: ((bstring * string list) * theory attribute list) list -> |
69 theory -> theory * thm list list |
69 theory -> thm list list * theory |
70 val add_axiomss_i: ((bstring * term list) * theory attribute list) list -> |
70 val add_axiomss_i: ((bstring * term list) * theory attribute list) list -> |
71 theory -> theory * thm list list |
71 theory -> thm list list * theory |
72 val add_defs: bool -> ((bstring * string) * theory attribute list) list -> |
72 val add_defs: bool -> ((bstring * string) * theory attribute list) list -> |
73 theory -> thm list * theory |
73 theory -> thm list * theory |
74 val add_defs_i: bool -> ((bstring * term) * theory attribute list) list -> |
74 val add_defs_i: bool -> ((bstring * term) * theory attribute list) list -> |
75 theory -> thm list * theory |
75 theory -> thm list * theory |
76 val add_defss: bool -> ((bstring * string list) * theory attribute list) list -> |
76 val add_defss: bool -> ((bstring * string list) * theory attribute list) list -> |
338 |
338 |
339 |
339 |
340 (* add_thms(s) *) |
340 (* add_thms(s) *) |
341 |
341 |
342 fun add_thms_atts pre_name ((bname, thms), atts) = |
342 fun add_thms_atts pre_name ((bname, thms), atts) = |
343 enter_thms pre_name (name_thms false) |
343 swap o enter_thms pre_name (name_thms false) |
344 (Thm.applys_attributes o rpair atts) (bname, thms); |
344 (Thm.applys_attributes o rpair atts) (bname, thms); |
345 |
345 |
346 fun gen_add_thmss pre_name args theory = |
346 fun gen_add_thmss pre_name = |
347 foldl_map (fn (thy, arg) => add_thms_atts pre_name arg thy) (theory, args); |
347 fold_map (add_thms_atts pre_name); |
348 |
348 |
349 fun gen_add_thms pre_name args = |
349 fun gen_add_thms pre_name args = |
350 apsnd (map hd) o gen_add_thmss pre_name (map (apfst (apsnd single)) args); |
350 apfst (map hd) o gen_add_thmss pre_name (map (apfst (apsnd single)) args); |
351 |
351 |
352 val add_thmss = gen_add_thmss (name_thms true); |
352 val add_thmss = gen_add_thmss (name_thms true); |
353 val add_thms = gen_add_thms (name_thms true); |
353 val add_thms = gen_add_thms (name_thms true); |
354 |
354 |
355 |
355 |
368 fun gen_note_thmss get kind_att args thy = |
368 fun gen_note_thmss get kind_att args thy = |
369 foldl_map (gen_note_thss get kind_att) (thy, args); |
369 foldl_map (gen_note_thss get kind_att) (thy, args); |
370 |
370 |
371 in |
371 in |
372 |
372 |
373 val note_thmss = gen_note_thmss get_thms; |
373 val note_thmss = swap ooo gen_note_thmss get_thms; |
374 val note_thmss_i = gen_note_thmss (K I); |
374 val note_thmss_i = swap ooo gen_note_thmss (K I); |
375 |
375 |
376 end; |
376 end; |
377 |
377 |
378 |
378 |
379 (* store_thm *) |
379 (* store_thm *) |
380 |
380 |
381 fun store_thm ((bname, thm), atts) thy = |
381 fun store_thm ((bname, thm), atts) thy = |
382 let val (thy', [th']) = add_thms_atts (name_thms true) ((bname, [thm]), atts) thy |
382 let val ([th'], thy') = add_thms_atts (name_thms true) ((bname, [thm]), atts) thy |
383 in (th', thy') end; |
383 in (th', thy') end; |
384 |
384 |
385 |
385 |
386 (* smart_store_thms(_open) *) |
386 (* smart_store_thms(_open) *) |
387 |
387 |
428 (* store axioms as theorems *) |
428 (* store axioms as theorems *) |
429 |
429 |
430 local |
430 local |
431 fun get_ax thy (name, _) = Thm.get_axiom_i thy (Sign.full_name thy name); |
431 fun get_ax thy (name, _) = Thm.get_axiom_i thy (Sign.full_name thy name); |
432 fun get_axs thy named_axs = map (forall_elim_vars 0 o get_ax thy) named_axs; |
432 fun get_axs thy named_axs = map (forall_elim_vars 0 o get_ax thy) named_axs; |
433 |
433 fun add_single add ((name, ax), atts) thy = |
434 fun add_single add (thy, ((name, ax), atts)) = |
|
435 let |
434 let |
436 val named_ax = [(name, ax)]; |
435 val named_ax = [(name, ax)]; |
437 val thy' = add named_ax thy; |
436 val thy' = add named_ax thy; |
438 val thm = hd (get_axs thy' named_ax); |
437 val thm = hd (get_axs thy' named_ax); |
439 in apsnd hd (gen_add_thms (K I) [((name, thm), atts)] thy') end; |
438 in apfst hd (gen_add_thms (K I) [((name, thm), atts)] thy') end; |
440 |
439 fun add_multi add ((name, axs), atts) thy = |
441 fun add_multi add (thy, ((name, axs), atts)) = |
|
442 let |
440 let |
443 val named_axs = name_multi name axs; |
441 val named_axs = name_multi name axs; |
444 val thy' = add named_axs thy; |
442 val thy' = add named_axs thy; |
445 val thms = get_axs thy' named_axs; |
443 val thms = get_axs thy' named_axs; |
446 in apsnd hd (gen_add_thmss (K I) [((name, thms), atts)] thy') end; |
444 in apfst hd (gen_add_thmss (K I) [((name, thms), atts)] thy') end; |
447 |
445 fun add_singles add = fold_map (add_single add); |
448 fun add_singles add args thy = foldl_map (add_single add) (thy, args); |
446 fun add_multis add = fold_map (add_multi add); |
449 fun add_multis add args thy = foldl_map (add_multi add) (thy, args); |
|
450 in |
447 in |
451 val add_axioms = add_singles Theory.add_axioms; |
448 val add_axioms = add_singles Theory.add_axioms; |
452 val add_axioms_i = add_singles Theory.add_axioms_i; |
449 val add_axioms_i = add_singles Theory.add_axioms_i; |
453 val add_axiomss = add_multis Theory.add_axioms; |
450 val add_axiomss = add_multis Theory.add_axioms; |
454 val add_axiomss_i = add_multis Theory.add_axioms_i; |
451 val add_axiomss_i = add_multis Theory.add_axioms_i; |
455 val add_defs = swap ooo add_singles o Theory.add_defs; |
452 val add_defs = add_singles o Theory.add_defs; |
456 val add_defs_i = swap ooo add_singles o Theory.add_defs_i; |
453 val add_defs_i = add_singles o Theory.add_defs_i; |
457 val add_defss = swap ooo add_multis o Theory.add_defs; |
454 val add_defss = add_multis o Theory.add_defs; |
458 val add_defss_i = swap ooo add_multis o Theory.add_defs_i; |
455 val add_defss_i = add_multis o Theory.add_defs_i; |
459 end; |
456 end; |
460 |
457 |
461 |
458 |
462 |
459 |
463 (*** ML setup ***) |
460 (*** ML setup ***) |
523 Const ("==>", [propT, propT] ---> propT), |
520 Const ("==>", [propT, propT] ---> propT), |
524 Const ("all", (aT --> propT) --> propT), |
521 Const ("all", (aT --> propT) --> propT), |
525 Const ("TYPE", a_itselfT), |
522 Const ("TYPE", a_itselfT), |
526 Const (Term.dummy_patternN, aT)] |
523 Const (Term.dummy_patternN, aT)] |
527 |> Theory.add_modesyntax ("", false) |
524 |> Theory.add_modesyntax ("", false) |
528 (Syntax.pure_syntax_output @ Syntax.pure_appl_syntax) |
525 (Syntax.pure_syntax_output @ Syntax.pure_appl_syntax) |
529 |> Theory.add_trfuns Syntax.pure_trfuns |
526 |> Theory.add_trfuns Syntax.pure_trfuns |
530 |> Theory.add_trfunsT Syntax.pure_trfunsT |
527 |> Theory.add_trfunsT Syntax.pure_trfunsT |
531 |> Sign.local_path |
528 |> Sign.local_path |
532 |> (snd oo (add_defs_i false o map Thm.no_attributes)) |
529 |> (add_defs_i false o map Thm.no_attributes) |
533 [("prop_def", Logic.mk_equals (Logic.protect A, A))] |
530 [("prop_def", Logic.mk_equals (Logic.protect A, A))] |> snd |
534 |> (#1 o add_thmss [(("nothing", []), [])]) |
531 |> add_thmss [(("nothing", []), [])] |> snd |
535 |> Theory.add_axioms_i Proofterm.equality_axms |
532 |> Theory.add_axioms_i Proofterm.equality_axms |
536 |> Theory.end_theory; |
533 |> Theory.end_theory; |
537 |
534 |
538 structure ProtoPure = |
535 structure ProtoPure = |
539 struct |
536 struct |