20 (((Name.binding * typ) * mixfix) list * (Attrib.binding * term list) list) * Proof.context |
20 (((Name.binding * typ) * mixfix) list * (Attrib.binding * term list) list) * Proof.context |
21 val read_free_specification: (Name.binding * string option * mixfix) list -> |
21 val read_free_specification: (Name.binding * string option * mixfix) list -> |
22 (Attrib.binding * string list) list -> Proof.context -> |
22 (Attrib.binding * string list) list -> Proof.context -> |
23 (((Name.binding * typ) * mixfix) list * (Attrib.binding * term list) list) * Proof.context |
23 (((Name.binding * typ) * mixfix) list * (Attrib.binding * term list) list) * Proof.context |
24 val axiomatization: (Name.binding * typ option * mixfix) list -> |
24 val axiomatization: (Name.binding * typ option * mixfix) list -> |
25 (Attrib.binding * term list) list -> local_theory -> |
25 (Attrib.binding * term list) list -> theory -> |
26 (term list * (string * thm list) list) * local_theory |
26 (term list * (string * thm list) list) * theory |
27 val axiomatization_cmd: (Name.binding * string option * mixfix) list -> |
27 val axiomatization_cmd: (Name.binding * string option * mixfix) list -> |
28 (Attrib.binding * string list) list -> local_theory -> |
28 (Attrib.binding * string list) list -> theory -> |
29 (term list * (string * thm list) list) * local_theory |
29 (term list * (string * thm list) list) * theory |
30 val definition: |
30 val definition: |
31 (Name.binding * typ option * mixfix) option * (Attrib.binding * term) -> |
31 (Name.binding * typ option * mixfix) option * (Attrib.binding * term) -> |
32 local_theory -> (term * (string * thm)) * local_theory |
32 local_theory -> (term * (string * thm)) * local_theory |
33 val definition_cmd: |
33 val definition_cmd: |
34 (Name.binding * string option * mixfix) option * (Attrib.binding * string) -> |
34 (Name.binding * string option * mixfix) option * (Attrib.binding * string) -> |
135 fun check_free_specification vars specs = check_spec false vars [specs]; |
135 fun check_free_specification vars specs = check_spec false vars [specs]; |
136 |
136 |
137 end; |
137 end; |
138 |
138 |
139 |
139 |
140 (* axiomatization *) |
140 (* axiomatization -- within global theory *) |
141 |
141 |
142 fun gen_axioms do_print prep raw_vars raw_specs lthy = |
142 fun gen_axioms do_print prep raw_vars raw_specs thy = |
143 let |
143 let |
144 val ((vars, specs), _) = prep raw_vars [raw_specs] lthy; |
144 val ((vars, specs), _) = prep raw_vars [raw_specs] (ProofContext.init thy); |
145 val ((consts, axioms), lthy') = LocalTheory.axioms Thm.axiomK (vars, specs) lthy; |
145 val xs = map (fn ((b, T), _) => (Name.name_of b, T)) vars; |
146 val consts' = map (Morphism.term (LocalTheory.target_morphism lthy')) consts; |
146 |
|
147 (*consts*) |
|
148 val (consts, consts_thy) = thy |> fold_map (Theory.specify_const []) vars; |
|
149 val subst = Term.subst_atomic (map Free xs ~~ consts); |
|
150 |
|
151 (*axioms*) |
|
152 val (axioms, axioms_thy) = consts_thy |> fold_map (fn ((b, atts), props) => |
|
153 fold_map Thm.add_axiom (PureThy.name_multi (Name.name_of b) (map subst props)) |
|
154 #>> (fn ths => ((b, atts), [(map Drule.standard' ths, [])]))) specs; |
|
155 val (facts, thy') = axioms_thy |> PureThy.note_thmss Thm.axiomK |
|
156 (Attrib.map_facts (Attrib.attribute_i axioms_thy) axioms); |
147 val _ = |
157 val _ = |
148 if not do_print then () |
158 if not do_print then () |
149 else print_consts lthy' (member (op =) (fold Term.add_frees consts' [])) |
159 else print_consts (ProofContext.init thy') (K false) xs; |
150 (map (fn ((b, T), _) => (Name.name_of b, T)) vars); |
160 in ((consts, facts), thy') end; |
151 in ((consts, axioms), lthy') end; |
|
152 |
161 |
153 val axiomatization = gen_axioms false check_specification; |
162 val axiomatization = gen_axioms false check_specification; |
154 val axiomatization_cmd = gen_axioms true read_specification; |
163 val axiomatization_cmd = gen_axioms true read_specification; |
155 |
164 |
156 |
165 |