105 is_finite : bool, |
105 is_finite : bool, |
106 take_induct_thms : thm list |
106 take_induct_thms : thm list |
107 } |
107 } |
108 |
108 |
109 val beta_ss = |
109 val beta_ss = |
110 simpset_of (put_simpset HOL_basic_ss @{context} |
110 simpset_of (put_simpset HOL_basic_ss \<^context> |
111 addsimps @{thms simp_thms} addsimprocs [@{simproc beta_cfun_proc}]) |
111 addsimps @{thms simp_thms} addsimprocs [\<^simproc>\<open>beta_cfun_proc\<close>]) |
112 |
112 |
113 (******************************************************************************) |
113 (******************************************************************************) |
114 (******************************** theory data *********************************) |
114 (******************************** theory data *********************************) |
115 (******************************************************************************) |
115 (******************************************************************************) |
116 |
116 |
125 |
125 |
126 fun add_rec_type (tname, bs) = |
126 fun add_rec_type (tname, bs) = |
127 Rec_Data.map (Symtab.insert (K true) (tname, bs)) |
127 Rec_Data.map (Symtab.insert (K true) (tname, bs)) |
128 |
128 |
129 fun add_deflation_thm thm = |
129 fun add_deflation_thm thm = |
130 Context.theory_map (Named_Theorems.add_thm @{named_theorems domain_deflation} thm) |
130 Context.theory_map (Named_Theorems.add_thm \<^named_theorems>\<open>domain_deflation\<close> thm) |
131 |
131 |
132 val get_rec_tab = Rec_Data.get |
132 val get_rec_tab = Rec_Data.get |
133 fun get_deflation_thms thy = |
133 fun get_deflation_thms thy = |
134 rev (Named_Theorems.get (Proof_Context.init_global thy) @{named_theorems domain_deflation}) |
134 rev (Named_Theorems.get (Proof_Context.init_global thy) \<^named_theorems>\<open>domain_deflation\<close>) |
135 |
135 |
136 val map_ID_add = Named_Theorems.add @{named_theorems domain_map_ID} |
136 val map_ID_add = Named_Theorems.add \<^named_theorems>\<open>domain_map_ID\<close> |
137 fun get_map_ID_thms thy = |
137 fun get_map_ID_thms thy = |
138 rev (Named_Theorems.get (Proof_Context.init_global thy) @{named_theorems domain_map_ID}) |
138 rev (Named_Theorems.get (Proof_Context.init_global thy) \<^named_theorems>\<open>domain_map_ID\<close>) |
139 |
139 |
140 |
140 |
141 (******************************************************************************) |
141 (******************************************************************************) |
142 (************************** building types and terms **************************) |
142 (************************** building types and terms **************************) |
143 (******************************************************************************) |
143 (******************************************************************************) |
147 infixr 6 ->> |
147 infixr 6 ->> |
148 infix -->> |
148 infix -->> |
149 infix 9 ` |
149 infix 9 ` |
150 |
150 |
151 fun mk_deflation t = |
151 fun mk_deflation t = |
152 Const (@{const_name deflation}, Term.fastype_of t --> boolT) $ t |
152 Const (\<^const_name>\<open>deflation\<close>, Term.fastype_of t --> boolT) $ t |
153 |
153 |
154 fun mk_eqs (t, u) = HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u)) |
154 fun mk_eqs (t, u) = HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u)) |
155 |
155 |
156 (******************************************************************************) |
156 (******************************************************************************) |
157 (****************************** isomorphism info ******************************) |
157 (****************************** isomorphism info ******************************) |
270 fold_map prove_chain_take (take_consts ~~ dbinds) thy |
270 fold_map prove_chain_take (take_consts ~~ dbinds) thy |
271 |
271 |
272 (* prove take_0 lemmas *) |
272 (* prove take_0 lemmas *) |
273 fun prove_take_0 ((take_const, dbind), (lhsT, _)) thy = |
273 fun prove_take_0 ((take_const, dbind), (lhsT, _)) thy = |
274 let |
274 let |
275 val lhs = take_const $ @{term "0::nat"} |
275 val lhs = take_const $ \<^term>\<open>0::nat\<close> |
276 val goal = mk_eqs (lhs, mk_bottom (lhsT ->> lhsT)) |
276 val goal = mk_eqs (lhs, mk_bottom (lhsT ->> lhsT)) |
277 val rules = take_defs @ @{thms iterate_0 fst_strict snd_strict} |
277 val rules = take_defs @ @{thms iterate_0 fst_strict snd_strict} |
278 fun tac ctxt = simp_tac (put_simpset HOL_basic_ss ctxt addsimps rules) 1 |
278 fun tac ctxt = simp_tac (put_simpset HOL_basic_ss ctxt addsimps rules) 1 |
279 val take_0_thm = Goal.prove_global thy [] [] goal (tac o #context) |
279 val take_0_thm = Goal.prove_global thy [] [] goal (tac o #context) |
280 in |
280 in |
287 val n = Free ("n", natT) |
287 val n = Free ("n", natT) |
288 val take_is = map (fn t => t $ n) take_consts |
288 val take_is = map (fn t => t $ n) take_consts |
289 fun prove_take_Suc |
289 fun prove_take_Suc |
290 (((take_const, rep_abs), dbind), (_, rhsT)) thy = |
290 (((take_const, rep_abs), dbind), (_, rhsT)) thy = |
291 let |
291 let |
292 val lhs = take_const $ (@{term Suc} $ n) |
292 val lhs = take_const $ (\<^term>\<open>Suc\<close> $ n) |
293 val body = map_of_typ thy (newTs ~~ take_is) rhsT |
293 val body = map_of_typ thy (newTs ~~ take_is) rhsT |
294 val rhs = mk_cfcomp2 (rep_abs, body) |
294 val rhs = mk_cfcomp2 (rep_abs, body) |
295 val goal = mk_eqs (lhs, rhs) |
295 val goal = mk_eqs (lhs, rhs) |
296 val simps = @{thms iterate_Suc fst_conv snd_conv} |
296 val simps = @{thms iterate_Suc fst_conv snd_conv} |
297 val rules = take_defs @ simps |
297 val rules = take_defs @ simps |
432 fun iso_locale (info : iso_info) = |
432 fun iso_locale (info : iso_info) = |
433 @{thm iso.intro} OF [#abs_inverse info, #rep_inverse info] |
433 @{thm iso.intro} OF [#abs_inverse info, #rep_inverse info] |
434 val iso_locale_thms = map iso_locale iso_infos |
434 val iso_locale_thms = map iso_locale iso_infos |
435 val decisive_abs_rep_thms = |
435 val decisive_abs_rep_thms = |
436 map (fn x => @{thm decisive_abs_rep} OF [x]) iso_locale_thms |
436 map (fn x => @{thm decisive_abs_rep} OF [x]) iso_locale_thms |
437 val n = Free ("n", @{typ nat}) |
437 val n = Free ("n", \<^typ>\<open>nat\<close>) |
438 fun mk_decisive t = |
438 fun mk_decisive t = |
439 Const (@{const_name decisive}, fastype_of t --> boolT) $ t |
439 Const (\<^const_name>\<open>decisive\<close>, fastype_of t --> boolT) $ t |
440 fun f take_const = mk_decisive (take_const $ n) |
440 fun f take_const = mk_decisive (take_const $ n) |
441 val goal = mk_trp (foldr1 mk_conj (map f take_consts)) |
441 val goal = mk_trp (foldr1 mk_conj (map f take_consts)) |
442 val rules0 = @{thm decisive_bottom} :: take_0_thms |
442 val rules0 = @{thm decisive_bottom} :: take_0_thms |
443 val rules1 = |
443 val rules1 = |
444 take_Suc_thms @ decisive_abs_rep_thms |
444 take_Suc_thms @ decisive_abs_rep_thms |
527 fold_map prove_reach_lemma |
527 fold_map prove_reach_lemma |
528 (chain_take_thms ~~ lub_take_thms ~~ dbinds) thy |
528 (chain_take_thms ~~ lub_take_thms ~~ dbinds) thy |
529 |
529 |
530 (* test for finiteness of domain definitions *) |
530 (* test for finiteness of domain definitions *) |
531 local |
531 local |
532 val types = [@{type_name ssum}, @{type_name sprod}] |
532 val types = [\<^type_name>\<open>ssum\<close>, \<^type_name>\<open>sprod\<close>] |
533 fun finite d T = if member (op =) absTs T then d else finite' d T |
533 fun finite d T = if member (op =) absTs T then d else finite' d T |
534 and finite' d (Type (c, Ts)) = |
534 and finite' d (Type (c, Ts)) = |
535 let val d' = d andalso member (op =) types c |
535 let val d' = d andalso member (op =) types c |
536 in forall (finite d') Ts end |
536 in forall (finite d') Ts end |
537 | finite' _ _ = true |
537 | finite' _ _ = true |