| author | huffman | 
| Mon, 07 Mar 2005 23:54:01 +0100 | |
| changeset 15587 | f363e6e080e7 | 
| parent 15570 | 8d8c70b41bab | 
| child 15596 | 8665d08085df | 
| permissions | -rw-r--r-- | 
| 5830 | 1 | (* Title: Pure/Isar/isar_thy.ML | 
| 2 | ID: $Id$ | |
| 3 | Author: Markus Wenzel, TU Muenchen | |
| 4 | ||
| 6371 | 5 | Pure/Isar derived theory operations. | 
| 5830 | 6 | *) | 
| 7 | ||
| 8 | signature ISAR_THY = | |
| 9 | sig | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 10 | val hide_space: string * xstring list -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 11 | val hide_space_i: string * string list -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 12 | val add_axioms: ((bstring * string) * Args.src list) list -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 13 | val add_axioms_i: ((bstring * term) * theory attribute list) list -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 14 | val add_defs: bool * ((bstring * string) * Args.src list) list -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 15 | val add_defs_i: bool * ((bstring * term) * theory attribute list) list -> theory -> theory | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 16 | val theorems: string -> ((bstring * Args.src list) * (thmref * Args.src list) list) list | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 17 | -> theory -> theory * (string * thm list) list | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 18 | val theorems_i: string -> | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 19 | ((bstring * theory attribute list) * (thm list * theory attribute list) list) list | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 20 | -> theory -> theory * (string * thm list) list | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 21 | val locale_theorems: string -> xstring -> | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 22 | ((bstring * Args.src list) * (thmref * Args.src list) list) list | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 23 | -> theory -> theory * (bstring * thm list) list | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 24 | val locale_theorems_i: string -> string -> | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 25 | ((bstring * Proof.context attribute list) | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 26 | * (thm list * Proof.context attribute list) list) list | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 27 | -> theory -> theory * (string * thm list) list | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 28 | val smart_theorems: string -> xstring option -> | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 29 | ((bstring * Args.src list) * (thmref * Args.src list) list) list | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 30 | -> theory -> theory * (string * thm list) list | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 31 | val declare_theorems: xstring option -> (thmref * Args.src list) list -> theory -> theory | 
| 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 32 | val apply_theorems: (thmref * Args.src list) list -> theory -> theory * thm list | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 33 | val apply_theorems_i: (thm list * theory attribute list) list -> theory -> theory * thm list | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 34 | val have_facts: ((string * Args.src list) * (thmref * Args.src list) list) list | 
| 10464 | 35 | -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 36 | val have_facts_i: ((string * Proof.context attribute list) * | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 37 | (thm * Proof.context attribute list) list) list -> ProofHistory.T -> ProofHistory.T | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 38 | val from_facts: (thmref * Args.src list) list list -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 39 | val from_facts_i: (thm * Proof.context attribute list) list list | 
| 6728 
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
 wenzelm parents: 
6688diff
changeset | 40 | -> ProofHistory.T -> ProofHistory.T | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 41 | val with_facts: (thmref * Args.src list) list list -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 42 | val with_facts_i: (thm * Proof.context attribute list) list list | 
| 6879 | 43 | -> ProofHistory.T -> ProofHistory.T | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 44 | val using_facts: (thmref * Args.src list) list list -> ProofHistory.T -> ProofHistory.T | 
| 12929 | 45 | val using_facts_i: (thm * Proof.context attribute list) list list | 
| 46 | -> ProofHistory.T -> ProofHistory.T | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 47 | val chain: ProofHistory.T -> ProofHistory.T | 
| 14528 
1457584110ac
Locale instantiation: label parameter optional, new attribute paramter.
 ballarin parents: 
14508diff
changeset | 48 | val instantiate_locale: (string * Args.src list) * string -> ProofHistory.T | 
| 
1457584110ac
Locale instantiation: label parameter optional, new attribute paramter.
 ballarin parents: 
14508diff
changeset | 49 | -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 50 | val fix: (string list * string option) list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 51 | val fix_i: (string list * typ option) list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 52 | val let_bind: (string list * string) list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 53 | val let_bind_i: (term list * term) list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 54 | val invoke_case: string * string option list * Args.src list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 55 | val invoke_case_i: string * string option list * Proof.context attribute list | 
| 11793 
5f0ab6f5c280
support impromptu terminology of cases parameters;
 wenzelm parents: 
11764diff
changeset | 56 | -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 57 | val theorem: string -> (bstring * Args.src list) * (string * (string list * string list)) | 
| 12141 | 58 | -> bool -> theory -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 59 | val theorem_i: string -> (bstring * theory attribute list) * | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 60 | (term * (term list * term list)) -> bool -> theory -> ProofHistory.T | 
| 12957 | 61 | val multi_theorem: string -> bstring * Args.src list | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 62 | -> Args.src Locale.element Locale.elem_expr list | 
| 12957 | 63 | -> ((bstring * Args.src list) * (string * (string list * string list)) list) list | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 64 | -> bool -> theory -> ProofHistory.T | 
| 12957 | 65 | val multi_theorem_i: string -> bstring * theory attribute list | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 66 | -> Proof.context attribute Locale.element_i Locale.elem_expr list | 
| 12957 | 67 | -> ((bstring * theory attribute list) * (term * (term list * term list)) list) list | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 68 | -> bool -> theory -> ProofHistory.T | 
| 12957 | 69 | val locale_multi_theorem: string -> xstring | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 70 | -> bstring * Args.src list -> Args.src Locale.element Locale.elem_expr list | 
| 12957 | 71 | -> ((bstring * Args.src list) * (string * (string list * string list)) list) list | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 72 | -> bool -> theory -> ProofHistory.T | 
| 12957 | 73 | val locale_multi_theorem_i: string -> string -> bstring * Proof.context attribute list | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 74 | -> Proof.context attribute Locale.element_i Locale.elem_expr list | 
| 12957 | 75 | -> ((bstring * Proof.context attribute list) * (term * (term list * term list)) list) list | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 76 | -> bool -> theory -> ProofHistory.T | 
| 15531 | 77 | val smart_multi_theorem: string -> xstring option | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 78 | -> bstring * Args.src list -> Args.src Locale.element Locale.elem_expr list | 
| 12957 | 79 | -> ((bstring * Args.src list) * (string * (string list * string list)) list) list | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 80 | -> bool -> theory -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 81 | val assume: ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 12141 | 82 | -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 83 | val assume_i: | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 84 | ((string * Proof.context attribute list) * (term * (term list * term list)) list) list | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 85 | -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 86 | val presume: ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 87 | -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 88 | val presume_i: | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 89 | ((string * Proof.context attribute list) * (term * (term list * term list)) list) list | 
| 12141 | 90 | -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 91 | val have: ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 12141 | 92 | -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 93 | val have_i: ((string * Proof.context attribute list) * | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 94 | (term * (term list * term list)) list) list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 95 | val hence: ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 12141 | 96 | -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 97 | val hence_i: ((string * Proof.context attribute list) * | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 98 | (term * (term list * term list)) list) list -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 99 | val show: ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 12141 | 100 | -> bool -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 101 | val show_i: ((string * Proof.context attribute list) * | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 102 | (term * (term list * term list)) list) list -> bool -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 103 | val thus: ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 12141 | 104 | -> bool -> ProofHistory.T -> ProofHistory.T | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 105 | val thus_i: ((string * Proof.context attribute list) | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 106 | * (term * (term list * term list)) list) list -> bool -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 107 | val local_def: (string * Args.src list) * (string * (string * string list)) | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 108 | -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 109 | val local_def_i: (string * Args.src list) * (string * (term * term list)) | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 110 | -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 111 | val obtain: (string list * string option) list | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 112 | * ((string * Args.src list) * (string * (string list * string list)) list) list | 
| 12969 | 113 | -> Toplevel.transition -> Toplevel.transition | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 114 | val obtain_i: (string list * typ option) list | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 115 | * ((string * Proof.context attribute list) * (term * (term list * term list)) list) list | 
| 12969 | 116 | -> Toplevel.transition -> Toplevel.transition | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 117 | val begin_block: ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 118 | val next_block: ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 119 | val end_block: ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 120 | val defer: int option -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 121 | val prefer: int -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 122 | val apply: Method.text -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 123 | val apply_end: Method.text -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 124 | val proof: Method.text option -> ProofHistory.T -> ProofHistory.T | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 125 | val qed: Method.text option -> Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 126 | val terminal_proof: Method.text * Method.text option | 
| 6937 | 127 | -> Toplevel.transition -> Toplevel.transition | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 128 | val default_proof: Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 129 | val immediate_proof: Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 130 | val done_proof: Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 131 | val skip_proof: Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 132 | val forget_proof: Toplevel.transition -> Toplevel.transition | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 133 | val get_thmss: (thmref * Args.src list) list -> Proof.state -> thm list | 
| 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 134 | val also: (thmref * Args.src list) list option -> Toplevel.transition -> Toplevel.transition | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 135 | val also_i: thm list option -> Toplevel.transition -> Toplevel.transition | 
| 15456 
956d6acacf89
Specific theorems in a named list of theorems can now be referred to
 berghofe parents: 
15237diff
changeset | 136 | val finally: (thmref * Args.src list) list option -> Toplevel.transition -> Toplevel.transition | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 137 | val finally_i: thm list option -> Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 138 | val moreover: Toplevel.transition -> Toplevel.transition | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 139 | val ultimately: Toplevel.transition -> Toplevel.transition | 
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 140 | val parse_ast_translation: bool * string -> theory -> theory | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 141 | val parse_translation: bool * string -> theory -> theory | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 142 | val print_translation: bool * string -> theory -> theory | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 143 | val typed_print_translation: bool * string -> theory -> theory | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 144 | val print_ast_translation: bool * string -> theory -> theory | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 145 | val token_translation: string -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 146 | val method_setup: bstring * string * string -> theory -> theory | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 147 | val add_oracle: bstring * string -> theory -> theory | 
| 13393 | 148 | val add_locale: bool * bstring * Locale.expr * Args.src Locale.element list -> theory -> theory | 
| 6331 | 149 | val begin_theory: string -> string list -> (string * bool) list -> theory | 
| 150 | val end_theory: theory -> theory | |
| 7932 | 151 | val kill_theory: string -> unit | 
| 6246 | 152 | val theory: string * string list * (string * bool) list | 
| 153 | -> Toplevel.transition -> Toplevel.transition | |
| 7960 | 154 |   val init_context: ('a -> unit) -> 'a -> Toplevel.transition -> Toplevel.transition
 | 
| 6246 | 155 | val context: string -> Toplevel.transition -> Toplevel.transition | 
| 5830 | 156 | end; | 
| 157 | ||
| 158 | structure IsarThy: ISAR_THY = | |
| 159 | struct | |
| 160 | ||
| 161 | ||
| 162 | (** derived theory and proof operations **) | |
| 163 | ||
| 8724 | 164 | (* name spaces *) | 
| 165 | ||
| 8885 | 166 | local | 
| 167 | ||
| 168 | val kinds = | |
| 10449 
088aa7bd3154
hide_space(_i): use Sign.certify_tycon, Sign.certify_tyabbr, Sign.certify_const;
 wenzelm parents: 
9903diff
changeset | 169 | [(Sign.classK, can o Sign.certify_class), | 
| 14778 | 170 | (Sign.typeK, can o Sign.certify_tyname), | 
| 10449 
088aa7bd3154
hide_space(_i): use Sign.certify_tycon, Sign.certify_tyabbr, Sign.certify_const;
 wenzelm parents: 
9903diff
changeset | 171 | (Sign.constK, can o Sign.certify_const)]; | 
| 8724 | 172 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 173 | fun gen_hide intern (kind, xnames) thy = | 
| 8885 | 174 | (case assoc (kinds, kind) of | 
| 15531 | 175 | SOME check => | 
| 8885 | 176 | let | 
| 177 | val sg = Theory.sign_of thy; | |
| 178 | val names = map (intern sg kind) xnames; | |
| 179 | val bads = filter_out (check sg) names; | |
| 180 | in | |
| 12589 | 181 | if null bads then Theory.hide_space_i true (kind, names) thy | 
| 8885 | 182 |         else error ("Attempt to hide undeclared item(s): " ^ commas_quote bads)
 | 
| 183 | end | |
| 15531 | 184 |   | NONE => error ("Bad name space specification: " ^ quote kind));
 | 
| 8885 | 185 | |
| 186 | in | |
| 187 | ||
| 188 | fun hide_space x = gen_hide Sign.intern x; | |
| 189 | fun hide_space_i x = gen_hide (K (K I)) x; | |
| 190 | ||
| 191 | end; | |
| 8724 | 192 | |
| 193 | ||
| 5830 | 194 | (* axioms and defs *) | 
| 195 | ||
| 5915 | 196 | fun add_axms f args thy = | 
| 197 | f (map (fn (x, srcs) => (x, map (Attrib.global_attribute thy) srcs)) args) thy; | |
| 198 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 199 | val add_axioms = add_axms (#1 oo PureThy.add_axioms); | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 200 | val add_axioms_i = #1 oo PureThy.add_axioms_i; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 201 | fun add_defs (x, args) = add_axms (#1 oo PureThy.add_defs x) args; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 202 | fun add_defs_i (x, args) = (#1 oo PureThy.add_defs_i x) args; | 
| 6371 | 203 | |
| 204 | ||
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 205 | (* attributes *) | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 206 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 207 | local | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 208 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 209 | fun prep_attribs f = map (fn ((name, more_srcs), th_srcs) => | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 210 | ((name, map f more_srcs), map (apsnd (map f)) th_srcs)); | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 211 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 212 | in | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 213 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 214 | fun global_attribs thy = prep_attribs (Attrib.global_attribute thy); | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 215 | fun local_attribs thy = prep_attribs (Attrib.local_attribute thy); | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 216 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 217 | end; | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 218 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 219 | |
| 5915 | 220 | (* theorems *) | 
| 221 | ||
| 12705 | 222 | local | 
| 223 | ||
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 224 | fun present_thmss kind (thy, named_thmss) = | 
| 13529 | 225 | (conditional (kind <> "" andalso kind <> Drule.internalK) (fn () => | 
| 15531 | 226 | Context.setmp (SOME thy) (Present.results (kind ^ "s")) named_thmss); | 
| 13529 | 227 | (thy, named_thmss)); | 
| 5915 | 228 | |
| 12705 | 229 | in | 
| 230 | ||
| 14564 | 231 | fun theorems_i k = present_thmss k oo PureThy.note_thmss_i (Drule.kind k); | 
| 232 | fun locale_theorems_i k loc = present_thmss k oo Locale.note_thmss_i k loc; | |
| 5915 | 233 | |
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 234 | fun theorems k args thy = thy | 
| 14564 | 235 | |> PureThy.note_thmss (Drule.kind k) (global_attribs thy args) | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 236 | |> present_thmss k; | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 237 | |
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 238 | fun locale_theorems k loc args thy = thy | 
| 14564 | 239 | |> Locale.note_thmss k loc (local_attribs thy args) | 
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 240 | |> present_thmss k; | 
| 6371 | 241 | |
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 242 | fun smart_theorems k opt_loc args thy = thy | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 243 | |> (case opt_loc of | 
| 15531 | 244 | NONE => PureThy.note_thmss (Drule.kind k) (global_attribs thy args) | 
| 245 | | SOME loc => Locale.note_thmss k loc (local_attribs thy args)) | |
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 246 | |> present_thmss k; | 
| 9590 | 247 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 248 | fun declare_theorems opt_loc args = #1 o smart_theorems "" opt_loc [(("", []), args)];
 | 
| 9590 | 249 | |
| 15570 | 250 | fun apply_theorems args = apsnd (List.concat o map snd) o theorems "" [(("", []), args)];
 | 
| 251 | fun apply_theorems_i args = apsnd (List.concat o map snd) o theorems_i "" [(("", []), args)];
 | |
| 6371 | 252 | |
| 12705 | 253 | end; | 
| 254 | ||
| 5915 | 255 | |
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 256 | (* facts and forward chaining *) | 
| 6371 | 257 | |
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 258 | fun local_thmss f args state = f (local_attribs (Proof.theory_of state) args) state; | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 259 | fun local_thmss_i f args = f (map (fn ((name, more_atts), th_atts) => | 
| 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 260 | ((name, more_atts), map (apfst single) th_atts)) args); | 
| 6371 | 261 | |
| 12713 
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
 wenzelm parents: 
12705diff
changeset | 262 | fun chain_thmss f args = ProofHistory.apply (Proof.chain o f (map (pair ("", [])) args));
 | 
| 6879 | 263 | |
| 14564 | 264 | val have_facts = ProofHistory.apply o local_thmss Proof.note_thmss; | 
| 265 | val have_facts_i = ProofHistory.apply o local_thmss_i Proof.note_thmss_i; | |
| 266 | val from_facts = chain_thmss (local_thmss Proof.note_thmss); | |
| 267 | val from_facts_i = chain_thmss (local_thmss_i Proof.note_thmss_i); | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 268 | val with_facts = chain_thmss (local_thmss Proof.with_thmss); | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 269 | val with_facts_i = chain_thmss (local_thmss_i Proof.with_thmss_i); | 
| 12929 | 270 | |
| 271 | fun using_facts args = ProofHistory.apply (fn state => | |
| 272 | Proof.using_thmss (map (map (apsnd (map | |
| 273 | (Attrib.local_attribute (Proof.theory_of state))))) args) state); | |
| 274 | ||
| 275 | val using_facts_i = ProofHistory.apply o Proof.using_thmss_i o map (map (apfst single)); | |
| 276 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 277 | val chain = ProofHistory.apply Proof.chain; | 
| 5830 | 278 | |
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 279 | |
| 14508 
859b11514537
Experimental command for instantiation of locales in proof contexts:
 ballarin parents: 
14503diff
changeset | 280 | (* locale instantiation *) | 
| 
859b11514537
Experimental command for instantiation of locales in proof contexts:
 ballarin parents: 
14503diff
changeset | 281 | |
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 282 | fun instantiate_locale ((name, atts), loc) = | 
| 14528 
1457584110ac
Locale instantiation: label parameter optional, new attribute paramter.
 ballarin parents: 
14508diff
changeset | 283 | ProofHistory.apply (fn state => | 
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 284 | Proof.instantiate_locale (loc, | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 285 | (name, map (Attrib.local_attribute (Proof.theory_of state)) atts)) state); | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 286 | |
| 5830 | 287 | |
| 288 | (* context *) | |
| 289 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 290 | val fix = ProofHistory.apply o Proof.fix; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 291 | val fix_i = ProofHistory.apply o Proof.fix_i; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 292 | val let_bind = ProofHistory.apply o Proof.let_bind; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 293 | val let_bind_i = ProofHistory.apply o Proof.let_bind_i; | 
| 8450 | 294 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 295 | fun invoke_case (name, xs, src) = ProofHistory.apply (fn state => | 
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 296 | Proof.invoke_case (name, xs, | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 297 | map (Attrib.local_attribute (Proof.theory_of state)) src) state); | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 298 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 299 | val invoke_case_i = ProofHistory.apply o Proof.invoke_case; | 
| 5830 | 300 | |
| 301 | ||
| 10935 | 302 | (* local results *) | 
| 303 | ||
| 304 | local | |
| 305 | ||
| 12244 | 306 | fun prt_facts ctxt = | 
| 15570 | 307 | List.concat o (separate [Pretty.fbrk, Pretty.str "and "]) o | 
| 13276 | 308 | map (single o ProofContext.pretty_fact ctxt); | 
| 12244 | 309 | |
| 310 | fun pretty_results ctxt ((kind, ""), facts) = | |
| 311 | Pretty.block (Pretty.str kind :: Pretty.brk 1 :: prt_facts ctxt facts) | |
| 312 | | pretty_results ctxt ((kind, name), facts) = Pretty.blk (1, | |
| 313 | [Pretty.str (kind ^ " " ^ name ^ ":"), Pretty.fbrk, | |
| 314 |         Pretty.blk (1, Pretty.str "(" :: prt_facts ctxt facts @ [Pretty.str ")"])]);
 | |
| 10935 | 315 | |
| 12055 | 316 | fun pretty_rule s ctxt thm = | 
| 10935 | 317 | Pretty.block [Pretty.str (s ^ " to solve goal by exported rule:"), | 
| 12055 | 318 | Pretty.fbrk, ProofContext.pretty_thm ctxt thm]; | 
| 10935 | 319 | |
| 320 | in | |
| 321 | ||
| 12244 | 322 | val print_result = Pretty.writeln oo pretty_results; | 
| 323 | fun print_result' ctxt (k, res) = print_result ctxt ((k, ""), res); | |
| 10935 | 324 | |
| 13686 | 325 | fun cond_print_result_rule int = if int | 
| 326 | then (print_result', | |
| 327 | priority oo (Pretty.string_of oo pretty_rule "Successful attempt")) | |
| 12055 | 328 | else (K (K ()), K (K ())); | 
| 10935 | 329 | |
| 330 | fun proof'' f = Toplevel.proof' (f o cond_print_result_rule); | |
| 331 | ||
| 332 | fun check_goal false state = state | |
| 333 | | check_goal true state = | |
| 334 | let | |
| 15531 | 335 | val rule = ref (NONE: thm option); | 
| 13529 | 336 | fun fail exn = | 
| 10935 | 337 | (["Problem! Local statement will fail to solve any pending goal"] @ | 
| 15531 | 338 | (case exn of NONE => [] | SOME e => [Toplevel.exn_message e]) @ | 
| 339 | (case ! rule of NONE => [] | SOME thm => | |
| 12055 | 340 | [Pretty.string_of (pretty_rule "Failed attempt" (Proof.context_of state) thm)])) | 
| 13529 | 341 | |> cat_lines |> error; | 
| 10935 | 342 | val check = | 
| 12055 | 343 | (fn () => Seq.pull (SkipProof.local_skip_proof (K (K ()), | 
| 15531 | 344 | fn _ => fn thm => rule := SOME thm) true state)) | 
| 14836 | 345 | |> setmp proofs 0 | 
| 346 | |> transform_error; | |
| 15531 | 347 | val result = (check (), NONE) handle Interrupt => raise Interrupt | e => (NONE, SOME e); | 
| 348 | in (case result of (SOME _, NONE) => () | (_, exn) => fail exn); state end; | |
| 12244 | 349 | |
| 10935 | 350 | end; | 
| 351 | ||
| 352 | ||
| 5830 | 353 | (* statements *) | 
| 354 | ||
| 7271 | 355 | local | 
| 356 | ||
| 12141 | 357 | fun global_attributes thy ((name, src), s) = ((name, map (Attrib.global_attribute thy) src), s); | 
| 12697 | 358 | fun local_attributes thy ((name, src), s) = ((name, map (Attrib.local_attribute thy) src), s); | 
| 359 | fun local_attributes' state = local_attributes (Proof.theory_of state); | |
| 6371 | 360 | |
| 12141 | 361 | fun global_statement f args int thy = | 
| 362 | ProofHistory.init (Toplevel.undo_limit int) (f (map (global_attributes thy) args) thy); | |
| 363 | fun global_statement_i f args int thy = ProofHistory.init (Toplevel.undo_limit int) (f args thy); | |
| 10935 | 364 | |
| 12141 | 365 | fun local_statement' f g args int = ProofHistory.apply (fn state => | 
| 12697 | 366 | f (map (local_attributes' state) args) int (g state)); | 
| 12141 | 367 | fun local_statement_i' f g args int = ProofHistory.apply (f args int o g); | 
| 368 | fun local_statement f g args = local_statement' (K o f) g args (); | |
| 369 | fun local_statement_i f g args = local_statement_i' (K o f) g args (); | |
| 7271 | 370 | |
| 12701 
77ac6d8451ea
export multi_theorem(_i), locale_multi_theorem(_i);
 wenzelm parents: 
12697diff
changeset | 371 | in | 
| 
77ac6d8451ea
export multi_theorem(_i), locale_multi_theorem(_i);
 wenzelm parents: 
12697diff
changeset | 372 | |
| 12957 | 373 | fun multi_theorem k a elems concl int thy = | 
| 15531 | 374 | global_statement (Proof.multi_theorem k NONE (apsnd (map (Attrib.global_attribute thy)) a) | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 375 | (map (Locale.map_attrib_elem_or_expr (Attrib.local_attribute thy)) elems)) concl int thy; | 
| 12697 | 376 | |
| 15531 | 377 | fun multi_theorem_i k a = global_statement_i o Proof.multi_theorem_i k NONE a; | 
| 12697 | 378 | |
| 12957 | 379 | fun locale_multi_theorem k locale (name, atts) elems concl int thy = | 
| 380 | global_statement (Proof.multi_theorem k | |
| 15531 | 381 | (SOME (locale, (map (Attrib.local_attribute thy) atts, | 
| 12957 | 382 | map (map (Attrib.local_attribute thy) o snd o fst) concl))) | 
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 383 | (name, []) (map (Locale.map_attrib_elem_or_expr (Attrib.local_attribute thy)) elems)) | 
| 12957 | 384 | (map (apfst (apsnd (K []))) concl) int thy; | 
| 12697 | 385 | |
| 12957 | 386 | fun locale_multi_theorem_i k locale (name, atts) elems concl = | 
| 15531 | 387 | global_statement_i (Proof.multi_theorem_i k (SOME (locale, (atts, map (snd o fst) concl))) | 
| 12957 | 388 | (name, []) elems) (map (apfst (apsnd (K []))) concl); | 
| 12697 | 389 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 390 | fun theorem k (a, t) = multi_theorem k a [] [(("", []), [t])];
 | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 391 | fun theorem_i k (a, t) = multi_theorem_i k a [] [(("", []), [t])];
 | 
| 11742 | 392 | |
| 15531 | 393 | fun smart_multi_theorem k NONE a elems = multi_theorem k a elems | 
| 394 | | smart_multi_theorem k (SOME locale) a elems = locale_multi_theorem k locale a elems; | |
| 11742 | 395 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 396 | val assume = local_statement Proof.assume I; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 397 | val assume_i = local_statement_i Proof.assume_i I; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 398 | val presume = local_statement Proof.presume I; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 399 | val presume_i = local_statement_i Proof.presume_i I; | 
| 12969 | 400 | val have = local_statement (Proof.have Seq.single true) I; | 
| 401 | val have_i = local_statement_i (Proof.have_i Seq.single true) I; | |
| 402 | val hence = local_statement (Proof.have Seq.single true) Proof.chain; | |
| 403 | val hence_i = local_statement_i (Proof.have_i Seq.single true) Proof.chain; | |
| 404 | val show = local_statement' (Proof.show check_goal Seq.single true) I; | |
| 405 | val show_i = local_statement_i' (Proof.show_i check_goal Seq.single true) I; | |
| 406 | val thus = local_statement' (Proof.show check_goal Seq.single true) Proof.chain; | |
| 407 | val thus_i = local_statement_i' (Proof.show_i check_goal Seq.single true) Proof.chain; | |
| 12141 | 408 | |
| 409 | fun gen_def f ((name, srcs), def) = ProofHistory.apply (fn state => | |
| 410 | f name (map (Attrib.local_attribute (Proof.theory_of state)) srcs) def state); | |
| 411 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 412 | val local_def = gen_def Proof.def; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 413 | val local_def_i = gen_def Proof.def_i; | 
| 5830 | 414 | |
| 12969 | 415 | fun obtain (xs, asms) = proof'' (ProofHistory.applys o (fn print => fn state => | 
| 416 | Obtain.obtain xs (map (local_attributes' state) asms) print state)); | |
| 11890 | 417 | |
| 12969 | 418 | fun obtain_i (xs, asms) = proof'' (ProofHistory.applys o Obtain.obtain_i xs asms); | 
| 11890 | 419 | |
| 7271 | 420 | end; | 
| 421 | ||
| 5830 | 422 | |
| 423 | (* blocks *) | |
| 424 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 425 | val begin_block = ProofHistory.apply Proof.begin_block; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 426 | val next_block = ProofHistory.apply Proof.next_block; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 427 | val end_block = ProofHistory.applys Proof.end_block; | 
| 5830 | 428 | |
| 429 | ||
| 8165 | 430 | (* shuffle state *) | 
| 431 | ||
| 8236 | 432 | fun shuffle meth i = Method.refine (Method.Basic (K (meth i))) o Proof.assert_no_chain; | 
| 8204 | 433 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 434 | fun defer i = ProofHistory.applys (shuffle Method.defer i); | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 435 | fun prefer i = ProofHistory.applys (shuffle Method.prefer i); | 
| 8165 | 436 | |
| 437 | ||
| 5830 | 438 | (* backward steps *) | 
| 439 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 440 | fun apply m = ProofHistory.applys | 
| 8881 | 441 | (Seq.map (Proof.goal_facts (K [])) o Method.refine m o Proof.assert_backward); | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 442 | fun apply_end m = ProofHistory.applys (Method.refine_end m o Proof.assert_forward); | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 443 | val proof = ProofHistory.applys o Method.proof; | 
| 6404 | 444 | |
| 445 | ||
| 446 | (* local endings *) | |
| 447 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 448 | val local_qed = proof'' o (ProofHistory.applys oo Method.local_qed true); | 
| 15237 
250e9be7a09d
Some changes to allow skipping of proof scripts.
 berghofe parents: 
15206diff
changeset | 449 | val skip_local_qed = | 
| 
250e9be7a09d
Some changes to allow skipping of proof scripts.
 berghofe parents: 
15206diff
changeset | 450 | Toplevel.skip_proof (History.apply (fn i => if i > 1 then i - 1 else raise Toplevel.UNDEF)); | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 451 | val local_terminal_proof = proof'' o (ProofHistory.applys oo Method.local_terminal_proof); | 
| 8966 | 452 | val local_default_proof = proof'' (ProofHistory.applys o Method.local_default_proof); | 
| 6904 
4125d6b6d8f9
removed proof history nesting commands (not useful);
 wenzelm parents: 
6890diff
changeset | 453 | val local_immediate_proof = proof'' (ProofHistory.applys o Method.local_immediate_proof); | 
| 8966 | 454 | val local_done_proof = proof'' (ProofHistory.applys o Method.local_done_proof); | 
| 12318 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 455 | val local_skip_proof = Toplevel.proof' (fn int => | 
| 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 456 | ProofHistory.applys (SkipProof.local_skip_proof (cond_print_result_rule int) int)); | 
| 6404 | 457 | |
| 458 | ||
| 459 | (* global endings *) | |
| 460 | ||
| 12318 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 461 | fun global_result finish = Toplevel.proof_to_theory' (fn int => fn prf => | 
| 6404 | 462 | let | 
| 463 | val state = ProofHistory.current prf; | |
| 464 | val _ = if Proof.at_bottom state then () else raise Toplevel.UNDEF; | |
| 12318 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 465 | val (thy, ((kind, name), res)) = finish int state; | 
| 11742 | 466 | in | 
| 467 | if kind = "" orelse kind = Drule.internalK then () | |
| 12244 | 468 | else (print_result (Proof.context_of state) ((kind, name), res); | 
| 15531 | 469 | Context.setmp (SOME thy) (Present.results kind) res); | 
| 11742 | 470 | thy | 
| 471 | end); | |
| 6404 | 472 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 473 | fun global_qed m = global_result (K (Method.global_qed true m)); | 
| 15237 
250e9be7a09d
Some changes to allow skipping of proof scripts.
 berghofe parents: 
15206diff
changeset | 474 | val skip_global_qed = Toplevel.skip_proof_to_theory (equal 1 o History.current); | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 475 | fun global_terminal_proof m = global_result (K (Method.global_terminal_proof m)); | 
| 12318 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 476 | val global_default_proof = global_result (K Method.global_default_proof); | 
| 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 477 | val global_immediate_proof = global_result (K Method.global_immediate_proof); | 
| 6888 
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
 wenzelm parents: 
6885diff
changeset | 478 | val global_skip_proof = global_result SkipProof.global_skip_proof; | 
| 12318 
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
 wenzelm parents: 
12271diff
changeset | 479 | val global_done_proof = global_result (K Method.global_done_proof); | 
| 6404 | 480 | |
| 481 | ||
| 482 | (* common endings *) | |
| 483 | ||
| 15237 
250e9be7a09d
Some changes to allow skipping of proof scripts.
 berghofe parents: 
15206diff
changeset | 484 | fun qed meth = local_qed meth o global_qed meth o skip_local_qed o skip_global_qed; | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 485 | fun terminal_proof meths = local_terminal_proof meths o global_terminal_proof meths; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 486 | val default_proof = local_default_proof o global_default_proof; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 487 | val immediate_proof = local_immediate_proof o global_immediate_proof; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 488 | val done_proof = local_done_proof o global_done_proof; | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 489 | val skip_proof = local_skip_proof o global_skip_proof; | 
| 15237 
250e9be7a09d
Some changes to allow skipping of proof scripts.
 berghofe parents: 
15206diff
changeset | 490 | val forget_proof = Toplevel.proof_to_theory (Proof.theory_of o ProofHistory.current) o | 
| 
250e9be7a09d
Some changes to allow skipping of proof scripts.
 berghofe parents: 
15206diff
changeset | 491 | Toplevel.skip_proof_to_theory (K true); | 
| 8210 | 492 | |
| 5830 | 493 | |
| 6774 | 494 | (* calculational proof commands *) | 
| 495 | ||
| 6879 | 496 | local | 
| 497 | ||
| 12055 | 498 | fun cond_print_calc int ctxt thms = | 
| 499 | if int then | |
| 500 | Pretty.writeln (Pretty.big_list "calculation:" (map (ProofContext.pretty_thm ctxt) thms)) | |
| 6774 | 501 | else (); | 
| 502 | ||
| 503 | fun proof''' f = Toplevel.proof' (f o cond_print_calc); | |
| 504 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 505 | fun gen_calc get f args prt state = | 
| 15570 | 506 | f (Option.map (fn srcs => get srcs state) args) prt state; | 
| 6879 | 507 | |
| 508 | in | |
| 509 | ||
| 14564 | 510 | fun get_thmss srcs = Proof.the_facts o local_thmss Proof.note_thmss [(("", []), srcs)];
 | 
| 7012 | 511 | fun get_thmss_i thms _ = thms; | 
| 512 | ||
| 6879 | 513 | fun also x = proof''' (ProofHistory.applys o gen_calc get_thmss Calculation.also x); | 
| 514 | fun also_i x = proof''' (ProofHistory.applys o gen_calc get_thmss_i Calculation.also x); | |
| 515 | fun finally x = proof''' (ProofHistory.applys o gen_calc get_thmss Calculation.finally x); | |
| 516 | fun finally_i x = proof''' (ProofHistory.applys o gen_calc get_thmss_i Calculation.finally x); | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 517 | val moreover = proof''' (ProofHistory.apply o Calculation.moreover); | 
| 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 518 | val ultimately = proof''' (ProofHistory.apply o Calculation.ultimately); | 
| 6879 | 519 | |
| 520 | end; | |
| 6774 | 521 | |
| 522 | ||
| 5830 | 523 | (* translation functions *) | 
| 524 | ||
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 525 | fun advancedT false = "" | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 526 | | advancedT true = "Sign.sg -> "; | 
| 5830 | 527 | |
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 528 | fun advancedN false = "" | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 529 | | advancedN true = "advanced_"; | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 530 | |
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 531 | fun parse_ast_translation (a, txt) = | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 532 |   txt |> Context.use_let ("val parse_ast_translation: (string * (" ^ advancedT a ^
 | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 533 | "Syntax.ast list -> Syntax.ast)) list") | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 534 |     ("Theory.add_" ^ advancedN a ^ "trfuns (parse_ast_translation, [], [], [])");
 | 
| 5830 | 535 | |
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 536 | fun parse_translation (a, txt) = | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 537 |   txt |> Context.use_let ("val parse_translation: (string * (" ^ advancedT a ^
 | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 538 | "term list -> term)) list") | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 539 |     ("Theory.add_" ^ advancedN a ^ "trfuns ([], parse_translation, [], [])");
 | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 540 | |
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 541 | fun print_translation (a, txt) = | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 542 |   txt |> Context.use_let ("val print_translation: (string * (" ^ advancedT a ^
 | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 543 | "term list -> term)) list") | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 544 |     ("Theory.add_" ^ advancedN a ^ "trfuns ([], [], print_translation, [])");
 | 
| 5830 | 545 | |
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 546 | fun print_ast_translation (a, txt) = | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 547 |   txt |> Context.use_let ("val print_ast_translation: (string * (" ^ advancedT a ^
 | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 548 | "Syntax.ast list -> Syntax.ast)) list") | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 549 |     ("Theory.add_" ^ advancedN a ^ "trfuns ([], [], [], print_ast_translation)");
 | 
| 5830 | 550 | |
| 14649 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 551 | fun typed_print_translation (a, txt) = | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 552 |   txt |> Context.use_let ("val typed_print_translation: (string * (" ^ advancedT a ^
 | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 553 | "bool -> typ -> term list -> term)) list") | 
| 
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
 wenzelm parents: 
14598diff
changeset | 554 |     ("Theory.add_" ^ advancedN a ^ "trfunsT typed_print_translation");
 | 
| 5830 | 555 | |
| 556 | val token_translation = | |
| 11717 
d808005e6e08
Fixed erroneous type constraint in token_translation function.
 berghofe parents: 
11048diff
changeset | 557 | Context.use_let "val token_translation: (string * string * (string -> string * real)) list" | 
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 558 | "Theory.add_tokentrfuns token_translation"; | 
| 5830 | 559 | |
| 560 | ||
| 9193 
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
 wenzelm parents: 
9032diff
changeset | 561 | (* add method *) | 
| 
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
 wenzelm parents: 
9032diff
changeset | 562 | |
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 563 | fun method_setup (name, txt, cmt) = | 
| 9193 
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
 wenzelm parents: 
9032diff
changeset | 564 | Context.use_let | 
| 9810 | 565 | "val thm = PureThy.get_thm_closure (Context.the_context ());\n\ | 
| 566 | \val thms = PureThy.get_thms_closure (Context.the_context ());\n\ | |
| 567 | \val method: bstring * (Args.src -> Proof.context -> Proof.method) * string" | |
| 9193 
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
 wenzelm parents: 
9032diff
changeset | 568 | "PureIsar.Method.add_method method" | 
| 14598 
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
 berghofe parents: 
14564diff
changeset | 569 |     ("(" ^ Library.quote name ^ ", " ^ txt ^ ", " ^ Library.quote cmt ^ ")");
 | 
| 9193 
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
 wenzelm parents: 
9032diff
changeset | 570 | |
| 
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
 wenzelm parents: 
9032diff
changeset | 571 | |
| 5830 | 572 | (* add_oracle *) | 
| 573 | ||
| 12876 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
 wenzelm parents: 
12848diff
changeset | 574 | fun add_oracle (name, txt) = | 
| 8349 
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
 wenzelm parents: 
8236diff
changeset | 575 | Context.use_let | 
| 9590 | 576 | "val oracle: bstring * (Sign.sg * Object.T -> term)" | 
| 5830 | 577 | "Theory.add_oracle oracle" | 
| 14598 
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
 berghofe parents: 
14564diff
changeset | 578 |     ("(" ^ Library.quote name ^ ", " ^ txt ^ ")");
 | 
| 5830 | 579 | |
| 580 | ||
| 12062 | 581 | (* add_locale *) | 
| 582 | ||
| 13393 | 583 | fun add_locale (do_pred, name, import, body) thy = | 
| 584 | Locale.add_locale do_pred name import | |
| 15206 
09d78ec709c7
Modified locales: improved implementation of "includes".
 ballarin parents: 
15127diff
changeset | 585 | (map (Locale.map_attrib_element (Attrib.local_attribute thy)) body) thy; | 
| 12062 | 586 | |
| 587 | ||
| 6688 | 588 | (* theory init and exit *) | 
| 5830 | 589 | |
| 8804 | 590 | fun gen_begin_theory upd name parents files = | 
| 14503 
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
 skalberg parents: 
13686diff
changeset | 591 | let val ml_filename = Path.pack (ThyLoad.ml_path name); | 
| 
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
 skalberg parents: 
13686diff
changeset | 592 | val () = if exists (equal ml_filename o #1) files | 
| 
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
 skalberg parents: 
13686diff
changeset | 593 | then error ((quote ml_filename) ^ " not allowed in files section for theory " ^ name) | 
| 
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
 skalberg parents: 
13686diff
changeset | 594 | else () | 
| 
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
 skalberg parents: 
13686diff
changeset | 595 | in ThyInfo.begin_theory Present.begin_theory upd name parents (map (apfst Path.unpack) files) end; | 
| 5830 | 596 | |
| 8804 | 597 | val begin_theory = gen_begin_theory false; | 
| 7909 | 598 | |
| 599 | fun end_theory thy = | |
| 7932 | 600 | if ThyInfo.check_known_thy (PureThy.get_name thy) then ThyInfo.end_theory thy | 
| 7909 | 601 | else thy; | 
| 602 | ||
| 7932 | 603 | val kill_theory = ThyInfo.if_known_thy ThyInfo.remove_thy; | 
| 6688 | 604 | |
| 7103 | 605 | |
| 8804 | 606 | fun bg_theory (name, parents, files) int = gen_begin_theory int name parents files; | 
| 6331 | 607 | fun en_theory thy = (end_theory thy; ()); | 
| 608 | ||
| 7932 | 609 | fun theory spec = Toplevel.init_theory (bg_theory spec) en_theory (kill_theory o PureThy.get_name); | 
| 6246 | 610 | |
| 611 | ||
| 612 | (* context switch *) | |
| 613 | ||
| 7960 | 614 | fun fetch_context f x = | 
| 15531 | 615 | (case Context.pass NONE f x of | 
| 616 | ((), NONE) => raise Toplevel.UNDEF | |
| 617 | | ((), SOME thy) => thy); | |
| 7960 | 618 | |
| 619 | fun init_context f x = Toplevel.init_theory (fn _ => fetch_context f x) (K ()) (K ()); | |
| 7953 | 620 | |
| 621 | val context = init_context (ThyInfo.quiet_update_thy true); | |
| 6246 | 622 | |
| 5830 | 623 | |
| 624 | end; |