166 val (def_thm, thy) = yield_singleton (PureThy.add_defs false) def thy; |
166 val (def_thm, thy) = yield_singleton (PureThy.add_defs false) def thy; |
167 in |
167 in |
168 ((const, def_thm), thy) |
168 ((const, def_thm), thy) |
169 end; |
169 end; |
170 |
170 |
|
171 fun add_qualified_def name (path, eqn) thy = |
|
172 thy |
|
173 |> Sign.add_path path |
|
174 |> yield_singleton (PureThy.add_defs false) |
|
175 (Thm.no_attributes (Binding.name name, eqn)) |
|
176 ||> Sign.parent_path; |
|
177 |
171 fun add_qualified_thm name (path, thm) thy = |
178 fun add_qualified_thm name (path, thm) thy = |
172 thy |
179 thy |
173 |> Sign.add_path path |
180 |> Sign.add_path path |
174 |> yield_singleton PureThy.add_thms |
181 |> yield_singleton PureThy.add_thms |
175 (Thm.no_attributes (Binding.name name, thm)) |
182 (Thm.no_attributes (Binding.name name, thm)) |
237 val take_bind = Binding.suffix_name "_take" tbind; |
244 val take_bind = Binding.suffix_name "_take" tbind; |
238 val (take_const, thy) = |
245 val (take_const, thy) = |
239 Sign.declare_const ((take_bind, take_type), NoSyn) thy; |
246 Sign.declare_const ((take_bind, take_type), NoSyn) thy; |
240 val take_eqn = Logic.mk_equals (take_const, take_rhs); |
247 val take_eqn = Logic.mk_equals (take_const, take_rhs); |
241 val (take_def_thm, thy) = |
248 val (take_def_thm, thy) = |
242 thy |
249 add_qualified_def "take_def" |
243 |> Sign.add_path (Binding.name_of tbind) |
250 (Binding.name_of tbind, take_eqn) thy; |
244 |> yield_singleton |
|
245 (PureThy.add_defs false o map Thm.no_attributes) |
|
246 (Binding.name "take_def", take_eqn) |
|
247 ||> Sign.parent_path; |
|
248 in ((take_const, take_def_thm), thy) end; |
251 in ((take_const, take_def_thm), thy) end; |
249 val ((take_consts, take_defs), thy) = thy |
252 val ((take_consts, take_defs), thy) = thy |
250 |> fold_map define_take_const (dom_binds ~~ take_rhss ~~ dom_eqns) |
253 |> fold_map define_take_const (dom_binds ~~ take_rhss ~~ dom_eqns) |
251 |>> ListPair.unzip; |
254 |>> ListPair.unzip; |
252 |
255 |
386 val finite_rhs = |
389 val finite_rhs = |
387 lambda x (HOLogic.exists_const natT $ |
390 lambda x (HOLogic.exists_const natT $ |
388 (lambda n (mk_eq (mk_capply (take_const $ n, x), x)))); |
391 (lambda n (mk_eq (mk_capply (take_const $ n, x), x)))); |
389 val finite_eqn = Logic.mk_equals (finite_const, finite_rhs); |
392 val finite_eqn = Logic.mk_equals (finite_const, finite_rhs); |
390 val (finite_def_thm, thy) = |
393 val (finite_def_thm, thy) = |
391 thy |
394 add_qualified_def "finite_def" |
392 |> Sign.add_path (Binding.name_of tbind) |
395 (Binding.name_of tbind, finite_eqn) thy; |
393 |> yield_singleton |
|
394 (PureThy.add_defs false o map Thm.no_attributes) |
|
395 (Binding.name "finite_def", finite_eqn) |
|
396 ||> Sign.parent_path; |
|
397 in ((finite_const, finite_def_thm), thy) end; |
396 in ((finite_const, finite_def_thm), thy) end; |
398 val ((finite_consts, finite_defs), thy) = thy |
397 val ((finite_consts, finite_defs), thy) = thy |
399 |> fold_map define_finite_const (dom_binds ~~ take_consts ~~ dom_eqns) |
398 |> fold_map define_finite_const (dom_binds ~~ take_consts ~~ dom_eqns) |
400 |>> ListPair.unzip; |
399 |>> ListPair.unzip; |
401 |
400 |