author  haftmann 
Sat, 17 Jan 2009 08:29:54 +0100  
changeset 29526  0b32c8b84d3e 
parent 29509  1ff0f3f08a7b 
child 29547  f2587922591e 
permissions  rwrr 
29358  1 
(* Title: Pure/Isar/ML 
24218  2 
Author: Florian Haftmann, TU Muenchen 
3 

29358  4 
Type classes derived from primitive axclasses and locales  interfaces 
24218  5 
*) 
6 

7 
signature CLASS = 

8 
sig 

29358  9 
include CLASS_TARGET 
29439  10 
(*FIXME the split into class_target.ML, theory_target.ML and 
11 
class.ML is artificial*) 

29358  12 

26247  13 
val class: bstring > class list > Element.context_i list 
29378  14 
> theory > string * local_theory 
26247  15 
val class_cmd: bstring > xstring list > Element.context list 
29378  16 
> theory > string * local_theory 
29358  17 
val prove_subclass: tactic > class > local_theory > local_theory 
18 
val subclass: class > local_theory > Proof.state 

19 
val subclass_cmd: xstring > local_theory > Proof.state 

24218  20 
end; 
21 

22 
structure Class : CLASS = 

23 
struct 

24 

29358  25 
open Class_Target; 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

26 

29358  27 
(** rule calculation **) 
24589  28 

28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

29 
fun calculate_axiom thy sups base_sort assm_axiom param_map class = 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

30 
case Locale.intros_of thy class 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

31 
of (_, NONE) => assm_axiom 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

32 
 (_, SOME intro) => 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

33 
let 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

34 
fun instantiate thy sort = Thm.instantiate ([pairself (Thm.ctyp_of thy o TVar o pair (Name.aT, 0)) 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

35 
(base_sort, sort)], map (fn (v, (c, ty)) => pairself (Thm.cterm_of thy) 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

36 
(Var ((v, 0), map_atyps (fn _ => TVar ((Name.aT, 0), sort)) ty), 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

37 
Const (c, map_atyps (fn _ => TVar ((Name.aT, 0), sort)) ty))) param_map); 
29358  38 
val axiom_premises = map_filter (fst o rules thy) sups 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

39 
@ the_list assm_axiom; 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

40 
in intro 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

41 
> instantiate thy [class] 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

42 
> (fn thm => thm OF axiom_premises) 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

43 
> Drule.standard' 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

44 
> Thm.close_derivation 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

45 
> SOME 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

46 
end; 
25024  47 

29526  48 
fun calculate_morphism thy class sups param_map some_axiom = 
29439  49 
let 
50 
val ctxt = ProofContext.init thy; 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

51 
val (([props], [(_, morph1)], export_morph), _) = ctxt 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

52 
> Expression.cert_goal_expression ([(class, (("", false), 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

53 
Expression.Named ((map o apsnd) Const param_map)))], []); 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

54 
val morph2 = morph1 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

55 
$> Morphism.binding_morphism (Binding.add_prefix false (class_prefix class)); 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

56 
val morph3 = case props 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

57 
of [prop] => morph2 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

58 
$> Element.satisfy_morphism [(Element.prove_witness ctxt prop 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

59 
(ALLGOALS (ProofContext.fact_tac (the_list some_axiom))))] 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

60 
 [] => morph2; 
29526  61 
val morph4 = morph3 $> Element.eq_morphism thy (these_defs thy sups); 
62 
in (morph3, morph4, export_morph) end; 

29439  63 

64 
fun calculate_rules thy morph sups base_sort param_map axiom class = 

25062  65 
let 
25711  66 
fun instantiate thy sort = Thm.instantiate ([pairself (Thm.ctyp_of thy o TVar o pair (Name.aT, 0)) 
67 
(base_sort, sort)], map (fn (v, (c, ty)) => pairself (Thm.cterm_of thy) 

68 
(Var ((v, 0), map_atyps (fn _ => TVar ((Name.aT, 0), sort)) ty), 

69 
Const (c, map_atyps (fn _ => TVar ((Name.aT, 0), sort)) ty))) param_map); 

70 
val defs = these_defs thy sups; 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

71 
val assm_intro = Locale.intros_of thy class 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

72 
> fst 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

73 
> Option.map (instantiate thy base_sort) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

74 
> Option.map (MetaSimplifier.rewrite_rule defs) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

75 
> Option.map Thm.close_derivation; 
25711  76 
val fixate = Thm.instantiate 
77 
(map (pairself (Thm.ctyp_of thy)) [(TVar ((Name.aT, 0), []), TFree (Name.aT, base_sort)), 

78 
(TVar ((Name.aT, 0), base_sort), TFree (Name.aT, base_sort))], []) 

25618  79 
val of_class_sups = if null sups 
25711  80 
then map (fixate o Thm.class_triv thy) base_sort 
29358  81 
else map (fixate o snd o rules thy) sups; 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

82 
val locale_dests = map Drule.standard' (Locale.axioms_of thy class); 
25711  83 
val num_trivs = case length locale_dests 
84 
of 0 => if is_none axiom then 0 else 1 

85 
 n => n; 

86 
val pred_trivs = if num_trivs = 0 then [] 

87 
else the axiom 

88 
> Thm.prop_of 

89 
> (map_types o map_atyps o K) (TFree (Name.aT, base_sort)) 

90 
> (Thm.assume o Thm.cterm_of thy) 

91 
> replicate num_trivs; 

28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

92 
val axclass_intro = (#intro o AxClass.get_info thy) class; 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

93 
val of_class = (fixate axclass_intro OF of_class_sups OF locale_dests OF pred_trivs) 
25711  94 
> Drule.standard' 
26628
63306cb94313
replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents:
26596
diff
changeset

95 
> Thm.close_derivation; 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

96 
in (assm_intro, of_class) end; 
24218  97 

98 

29358  99 
(** define classes **) 
24218  100 

101 
local 

102 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

103 
fun gen_class_spec prep_class process_decl thy raw_supclasses raw_elems = 
24218  104 
let 
29526  105 
(*FIXME 2009 simplify*) 
24748  106 
val supclasses = map (prep_class thy) raw_supclasses; 
107 
val supsort = Sign.minimize_sort thy supclasses; 

25618  108 
val sups = filter (is_class thy) supsort; 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

109 
val base_sort = if null sups then supsort else 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

110 
foldr1 (Sorts.inter_sort (Sign.classes_of thy)) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

111 
(map (base_sort thy) sups); 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

112 
val supparams = (map o apsnd) (snd o snd) (these_params thy sups); 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

113 
val supparam_names = map fst supparams; 
26995  114 
val _ = if has_duplicates (op =) supparam_names 
115 
then error ("Duplicate parameter(s) in superclasses: " 

116 
^ (commas o map quote o duplicates (op =)) supparam_names) 

117 
else (); 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

118 

1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

119 
val supexpr = (map (fn sup => (sup, (("", false), Expression.Positional []))) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

120 
sups, []); 
24748  121 
val constrain = Element.Constrains ((map o apsnd o map_atyps) 
26167  122 
(K (TFree (Name.aT, base_sort))) supparams); 
29526  123 
(*FIXME 2009 perhaps better: control type variable by explicit 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

124 
parameter instantiation of import expression*) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

125 
val begin_ctxt = begin sups base_sort 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

126 
#> fold (Variable.declare_constraints o Free) ((map o apsnd o map_atyps) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

127 
(K (TFree (Name.aT, base_sort))) supparams) (*FIXME 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

128 
should constraints be issued in begin?*) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

129 
val ((_, _, syntax_elems), _) = ProofContext.init thy 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

130 
> begin_ctxt 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

131 
> process_decl supexpr raw_elems; 
25683  132 
fun fork_syn (Element.Fixes xs) = 
29006  133 
fold_map (fn (c, ty, syn) => cons (Binding.base_name c, syn) #> pair (c, ty, NoSyn)) xs 
25683  134 
#>> Element.Fixes 
135 
 fork_syn x = pair x; 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

136 
val (elems, global_syntax) = fold_map fork_syn syntax_elems []; 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

137 
in (((sups, supparam_names), (supsort, base_sort, supexpr)), (constrain :: elems, global_syntax)) end; 
24748  138 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

139 
val cert_class_spec = gen_class_spec (K I) Expression.cert_declaration; 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

140 
val read_class_spec = gen_class_spec Sign.intern_class Expression.cert_read_declaration; 
24748  141 

28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

142 
fun add_consts bname class base_sort sups supparams global_syntax thy = 
24968
f9bafc868847
replaced Sign.add_consts_authentic by Sign.declare_const;
wenzelm
parents:
24949
diff
changeset

143 
let 
29526  144 
(*FIXME 2009 simplify*) 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

145 
val supconsts = supparams 
26518  146 
> AList.make (snd o the o AList.lookup (op =) (these_params thy sups)) 
25683  147 
> (map o apsnd o apsnd o map_atyps o K o TFree) (Name.aT, [class]); 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

148 
val all_params = Locale.params_of thy class; 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

149 
val raw_params = (snd o chop (length supparams)) all_params; 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

150 
fun add_const (b, SOME raw_ty, _) thy = 
25683  151 
let 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

152 
val v = Binding.base_name b; 
28965  153 
val c = Sign.full_bname thy v; 
25683  154 
val ty = map_atyps (K (TFree (Name.aT, base_sort))) raw_ty; 
155 
val ty0 = Type.strip_sorts ty; 

156 
val ty' = map_atyps (K (TFree (Name.aT, [class]))) ty0; 

157 
val syn = (the_default NoSyn o AList.lookup (op =) global_syntax) v; 

158 
in 

159 
thy 

28965  160 
> Sign.declare_const [] ((Binding.name v, ty0), syn) 
25683  161 
> snd 
162 
> pair ((v, ty), (c, ty')) 

163 
end; 

28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

164 
in 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

165 
thy 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

166 
> Sign.add_path (Logic.const_of_class bname) 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

167 
> fold_map add_const raw_params 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

168 
> Sign.restore_naming thy 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

169 
> (fn params => pair (supconsts @ (map o apfst) fst params, params)) 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

170 
end; 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

171 

238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

172 
fun adjungate_axclass bname class base_sort sups supsort supparams global_syntax thy = 
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

173 
let 
29526  174 
(*FIXME 2009 simplify*) 
25683  175 
fun globalize param_map = map_aterms 
176 
(fn Free (v, ty) => Const ((fst o the o AList.lookup (op =) param_map) v, ty) 

177 
 t => t); 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

178 
val raw_pred = Locale.intros_of thy class 
25683  179 
> fst 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

180 
> Option.map (Logic.unvarify o Logic.strip_imp_concl o Thm.prop_of); 
25683  181 
fun get_axiom thy = case (#axioms o AxClass.get_info thy) class 
182 
of [] => NONE 

183 
 [thm] => SOME thm; 

24968
f9bafc868847
replaced Sign.add_consts_authentic by Sign.declare_const;
wenzelm
parents:
24949
diff
changeset

184 
in 
f9bafc868847
replaced Sign.add_consts_authentic by Sign.declare_const;
wenzelm
parents:
24949
diff
changeset

185 
thy 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

186 
> add_consts bname class base_sort sups supparams global_syntax 
25683  187 
> (fn (param_map, params) => AxClass.define_class (bname, supsort) 
26518  188 
(map (fst o snd) params) 
29526  189 
[((Binding.empty, []), 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

190 
Option.map (globalize param_map) raw_pred > the_list)] 
25683  191 
#> snd 
192 
#> `get_axiom 

193 
#> (fn assm_axiom => fold (Sign.add_const_constraint o apsnd SOME o snd) params 

29526  194 
#> pair (param_map, params, assm_axiom))) 
24968
f9bafc868847
replaced Sign.add_consts_authentic by Sign.declare_const;
wenzelm
parents:
24949
diff
changeset

195 
end; 
f9bafc868847
replaced Sign.add_consts_authentic by Sign.declare_const;
wenzelm
parents:
24949
diff
changeset

196 

26518  197 
fun gen_class prep_spec bname raw_supclasses raw_elems thy = 
24748  198 
let 
28965  199 
val class = Sign.full_bname thy bname; 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

200 
val (((sups, supparams), (supsort, base_sort, supexpr)), (elems, global_syntax)) = 
26247  201 
prep_spec thy raw_supclasses raw_elems; 
24218  202 
in 
203 
thy 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

204 
> Expression.add_locale bname "" supexpr elems 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

205 
> snd > LocalTheory.exit_global 
26518  206 
> adjungate_axclass bname class base_sort sups supsort supparams global_syntax 
29526  207 
> (fn (param_map, params, assm_axiom) => 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

208 
`(fn thy => calculate_axiom thy sups base_sort assm_axiom param_map class) 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

209 
#> (fn axiom => 
29526  210 
`(fn thy => calculate_morphism thy class sups param_map axiom) 
211 
#> (fn (raw_morph, morph, export_morph) => Locale.add_registration (class, (morph, export_morph)) 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

212 
#> Locale.activate_global_facts (class, morph $> export_morph) 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

213 
#> `(fn thy => calculate_rules thy morph sups base_sort param_map axiom class) 
28715
238f9966c80e
class morphism stemming from locale interpretation
haftmann
parents:
28674
diff
changeset

214 
#> (fn (assm_intro, of_class) => 
29526  215 
register class sups params base_sort raw_morph axiom assm_intro of_class)))) 
29378  216 
> TheoryTarget.init (SOME class) 
25038  217 
> pair class 
24218  218 
end; 
219 

220 
in 

221 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

222 
val class = gen_class cert_class_spec; 
26518  223 
val class_cmd = gen_class read_class_spec; 
24218  224 

225 
end; (*local*) 

226 

227 

29358  228 
(** subclass relations **) 
25462  229 

29358  230 
local 
25462  231 

29358  232 
fun gen_subclass prep_class do_proof raw_sup lthy = 
25462  233 
let 
29358  234 
val thy = ProofContext.theory_of lthy; 
235 
val sup = prep_class thy raw_sup; 

236 
val sub = case TheoryTarget.peek lthy 

237 
of {is_class = false, ...} => error "Not a class context" 

238 
 {target, ...} => target; 

29526  239 

29358  240 
val _ = if Sign.subsort thy ([sup], [sub]) 
241 
then error ("Class " ^ Syntax.string_of_sort lthy [sup] 

242 
^ " is subclass of class " ^ Syntax.string_of_sort lthy [sub]) 

243 
else (); 

244 
val sub_params = map fst (these_params thy [sub]); 

245 
val sup_params = map fst (these_params thy [sup]); 

246 
val err_params = subtract (op =) sub_params sup_params; 

247 
val _ = if null err_params then [] else 

248 
error ("Class " ^ Syntax.string_of_sort lthy [sub] ^ " lacks parameter(s) " ^ 

249 
commas_quote err_params ^ " of " ^ Syntax.string_of_sort lthy [sup]); 

29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

250 

1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

251 
val expr = ([(sup, (("", false), Expression.Positional []))], []); 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

252 
val (([props], _, _), goal_ctxt) = 
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

253 
Expression.cert_goal_expression expr lthy; 
29526  254 
val some_prop = try the_single props; 
255 

256 
fun tac some_thm = ALLGOALS (ProofContext.fact_tac (the_list some_thm)); 

257 
fun prove_sublocale some_thm = 

258 
Expression.sublocale sub expr 

259 
#> Proof.global_terminal_proof 

260 
(Method.Basic (K (Method.SIMPLE_METHOD (tac some_thm)), Position.none), NONE) 

261 
#> ProofContext.theory_of; 

29358  262 
fun after_qed some_thm = 
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29439
diff
changeset

263 
LocalTheory.theory (register_subclass (sub, sup) some_thm) 
29526  264 
#> is_some some_thm ? LocalTheory.theory (prove_sublocale some_thm) 
265 
(*FIXME should also go to register_subclass*) 

266 
#> ProofContext.theory_of 

267 
#> TheoryTarget.init (SOME sub); 

268 
in do_proof after_qed some_prop lthy end; 

25485  269 

29358  270 
fun user_proof after_qed NONE = 
271 
Proof.theorem_i NONE (K (after_qed NONE)) [[]] 

272 
 user_proof after_qed (SOME prop) = 

273 
Proof.theorem_i NONE (after_qed o try the_single o the_single) [[(prop, [])]]; 

25485  274 

29358  275 
fun tactic_proof tac after_qed NONE lthy = 
276 
after_qed NONE lthy 

277 
 tactic_proof tac after_qed (SOME prop) lthy = 

278 
after_qed (SOME (Goal.prove (LocalTheory.target_of lthy) [] [] prop 

279 
(K tac))) lthy; 

28666  280 

29358  281 
in 
28666  282 

29358  283 
val subclass = gen_subclass (K I) user_proof; 
284 
fun prove_subclass tac = gen_subclass (K I) (tactic_proof tac); 

285 
val subclass_cmd = gen_subclass Sign.read_class user_proof; 

25462  286 

29358  287 
end; (*local*) 
288 

25603  289 

24218  290 
end; 
25683  291 