7 |
7 |
8 val HOLCF_ss = @{simpset}; |
8 val HOLCF_ss = @{simpset}; |
9 |
9 |
10 signature DOMAIN_THEOREMS = |
10 signature DOMAIN_THEOREMS = |
11 sig |
11 sig |
12 val theorems: Domain_Library.eq * Domain_Library.eq list -> theory -> thm list * theory; |
12 val theorems: |
|
13 Domain_Library.eq * Domain_Library.eq list |
|
14 -> typ * (binding * (bool * binding option * typ) list * mixfix) list |
|
15 -> theory -> thm list * theory; |
|
16 |
13 val comp_theorems: bstring * Domain_Library.eq list -> theory -> thm list * theory; |
17 val comp_theorems: bstring * Domain_Library.eq list -> theory -> thm list * theory; |
14 val quiet_mode: bool Unsynchronized.ref; |
18 val quiet_mode: bool Unsynchronized.ref; |
15 val trace_domain: bool Unsynchronized.ref; |
19 val trace_domain: bool Unsynchronized.ref; |
16 end; |
20 end; |
17 |
21 |
133 |
137 |
134 val all2E = @{lemma "!x y . P x y ==> (P x y ==> R) ==> R" by simp} |
138 val all2E = @{lemma "!x y . P x y ==> (P x y ==> R) ==> R" by simp} |
135 |
139 |
136 val dist_eqI = @{lemma "!!x::'a::po. ~ x << y ==> x ~= y" by (blast dest!: below_antisym_inverse)} |
140 val dist_eqI = @{lemma "!!x::'a::po. ~ x << y ==> x ~= y" by (blast dest!: below_antisym_inverse)} |
137 |
141 |
138 fun theorems (((dname, _), cons) : eq, eqs : eq list) thy = |
142 fun theorems |
|
143 (((dname, _), cons) : eq, eqs : eq list) |
|
144 (dom_eqn : typ * (binding * (bool * binding option * typ) list * mixfix) list) |
|
145 (thy : theory) = |
139 let |
146 let |
140 |
147 |
141 val _ = message ("Proving isomorphism properties of domain "^dname^" ..."); |
148 val _ = message ("Proving isomorphism properties of domain "^dname^" ..."); |
142 val pg = pg' thy; |
|
143 val map_tab = Domain_Isomorphism.get_map_tab thy; |
149 val map_tab = Domain_Isomorphism.get_map_tab thy; |
144 |
150 |
145 |
151 |
146 (* ----- getting the axioms and definitions --------------------------------- *) |
152 (* ----- getting the axioms and definitions --------------------------------- *) |
147 |
153 |
150 in |
156 in |
151 val ax_abs_iso = ga "abs_iso" dname; |
157 val ax_abs_iso = ga "abs_iso" dname; |
152 val ax_rep_iso = ga "rep_iso" dname; |
158 val ax_rep_iso = ga "rep_iso" dname; |
153 val ax_when_def = ga "when_def" dname; |
159 val ax_when_def = ga "when_def" dname; |
154 fun get_def mk_name (con, _, _) = ga (mk_name con^"_def") dname; |
160 fun get_def mk_name (con, _, _) = ga (mk_name con^"_def") dname; |
155 val axs_con_def = map (get_def extern_name) cons; |
|
156 val axs_dis_def = map (get_def dis_name) cons; |
161 val axs_dis_def = map (get_def dis_name) cons; |
157 val axs_mat_def = map (get_def mat_name) cons; |
162 val axs_mat_def = map (get_def mat_name) cons; |
158 val axs_pat_def = map (get_def pat_name) cons; |
163 val axs_pat_def = map (get_def pat_name) cons; |
159 val axs_sel_def = |
164 val axs_sel_def = |
160 let |
165 let |
165 maps defs_of_con cons |
170 maps defs_of_con cons |
166 end; |
171 end; |
167 val ax_copy_def = ga "copy_def" dname; |
172 val ax_copy_def = ga "copy_def" dname; |
168 end; (* local *) |
173 end; (* local *) |
169 |
174 |
|
175 (* ----- define constructors ------------------------------------------------ *) |
|
176 |
|
177 val lhsT = fst dom_eqn; |
|
178 |
|
179 val rhsT = |
|
180 let |
|
181 fun mk_arg_typ (lazy, sel, T) = if lazy then mk_uT T else T; |
|
182 fun mk_con_typ (bind, args, mx) = |
|
183 if null args then oneT else foldr1 mk_sprodT (map mk_arg_typ args); |
|
184 fun mk_eq_typ (_, cons) = foldr1 mk_ssumT (map mk_con_typ cons); |
|
185 in |
|
186 mk_eq_typ dom_eqn |
|
187 end; |
|
188 |
|
189 val rep_const = Const(dname^"_rep", lhsT ->> rhsT); |
|
190 |
|
191 val abs_const = Const(dname^"_abs", rhsT ->> lhsT); |
|
192 |
|
193 val (result, thy) = |
|
194 Domain_Constructors.add_domain_constructors |
|
195 (Long_Name.base_name dname) dom_eqn |
|
196 (rep_const, abs_const) (ax_rep_iso, ax_abs_iso) thy; |
|
197 |
|
198 val axs_con_def = #con_defs result; |
|
199 |
170 (* ----- theorems concerning the isomorphism -------------------------------- *) |
200 (* ----- theorems concerning the isomorphism -------------------------------- *) |
|
201 |
|
202 val pg = pg' thy; |
171 |
203 |
172 val dc_abs = %%:(dname^"_abs"); |
204 val dc_abs = %%:(dname^"_abs"); |
173 val dc_rep = %%:(dname^"_rep"); |
205 val dc_rep = %%:(dname^"_rep"); |
174 val dc_copy = %%:(dname^"_copy"); |
206 val dc_copy = %%:(dname^"_copy"); |
175 val x_name = "x"; |
207 val x_name = "x"; |
709 in |
741 in |
710 val axs_reach = map (ga "reach" ) dnames; |
742 val axs_reach = map (ga "reach" ) dnames; |
711 val axs_take_def = map (ga "take_def" ) dnames; |
743 val axs_take_def = map (ga "take_def" ) dnames; |
712 val axs_finite_def = map (ga "finite_def") dnames; |
744 val axs_finite_def = map (ga "finite_def") dnames; |
713 val ax_copy2_def = ga "copy_def" comp_dnam; |
745 val ax_copy2_def = ga "copy_def" comp_dnam; |
|
746 (* TEMPORARILY DISABLED |
714 val ax_bisim_def = ga "bisim_def" comp_dnam; |
747 val ax_bisim_def = ga "bisim_def" comp_dnam; |
|
748 TEMPORARILY DISABLED *) |
715 end; |
749 end; |
716 |
750 |
717 local |
751 local |
718 fun gt s dn = PureThy.get_thm thy (dn ^ "." ^ s); |
752 fun gt s dn = PureThy.get_thm thy (dn ^ "." ^ s); |
719 fun gts s dn = PureThy.get_thms thy (dn ^ "." ^ s); |
753 fun gts s dn = PureThy.get_thms thy (dn ^ "." ^ s); |
1029 |
1063 |
1030 end; (* local *) |
1064 end; (* local *) |
1031 |
1065 |
1032 (* ----- theorem concerning coinduction ------------------------------------- *) |
1066 (* ----- theorem concerning coinduction ------------------------------------- *) |
1033 |
1067 |
|
1068 (* COINDUCTION TEMPORARILY DISABLED |
1034 local |
1069 local |
1035 val xs = mapn (fn n => K (x_name n)) 1 dnames; |
1070 val xs = mapn (fn n => K (x_name n)) 1 dnames; |
1036 fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1); |
1071 fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1); |
1037 val take_ss = HOL_ss addsimps take_rews; |
1072 val take_ss = HOL_ss addsimps take_rews; |
1038 val sproj = prj (fn s => K("fst("^s^")")) (fn s => K("snd("^s^")")); |
1073 val sproj = prj (fn s => K("fst("^s^")")) (fn s => K("snd("^s^")")); |
1079 cut_facts_tac [coind_lemma] 1, |
1114 cut_facts_tac [coind_lemma] 1, |
1080 fast_tac HOL_cs 1]) |
1115 fast_tac HOL_cs 1]) |
1081 take_lemmas; |
1116 take_lemmas; |
1082 in pg [] goal (K tacs) end; |
1117 in pg [] goal (K tacs) end; |
1083 end; (* local *) |
1118 end; (* local *) |
|
1119 COINDUCTION TEMPORARILY DISABLED *) |
1084 |
1120 |
1085 val inducts = Project_Rule.projections (ProofContext.init thy) ind; |
1121 val inducts = Project_Rule.projections (ProofContext.init thy) ind; |
1086 fun ind_rule (dname, rule) = ((Binding.empty, [rule]), [Induct.induct_type dname]); |
1122 fun ind_rule (dname, rule) = ((Binding.empty, [rule]), [Induct.induct_type dname]); |
1087 val induct_failed = (Thm.prop_of ind = Thm.prop_of TrueI); |
1123 val induct_failed = (Thm.prop_of ind = Thm.prop_of TrueI); |
1088 |
1124 |
1090 |> snd o PureThy.add_thmss [ |
1126 |> snd o PureThy.add_thmss [ |
1091 ((Binding.name "take_rews" , take_rews ), [Simplifier.simp_add]), |
1127 ((Binding.name "take_rews" , take_rews ), [Simplifier.simp_add]), |
1092 ((Binding.name "take_lemmas", take_lemmas ), []), |
1128 ((Binding.name "take_lemmas", take_lemmas ), []), |
1093 ((Binding.name "finites" , finites ), []), |
1129 ((Binding.name "finites" , finites ), []), |
1094 ((Binding.name "finite_ind" , [finite_ind]), []), |
1130 ((Binding.name "finite_ind" , [finite_ind]), []), |
1095 ((Binding.name "ind" , [ind] ), []), |
1131 ((Binding.name "ind" , [ind] ), [])(*, |
1096 ((Binding.name "coind" , [coind] ), [])] |
1132 ((Binding.name "coind" , [coind] ), [])*)] |
1097 |> (if induct_failed then I |
1133 |> (if induct_failed then I |
1098 else snd o PureThy.add_thmss (map ind_rule (dnames ~~ inducts))) |
1134 else snd o PureThy.add_thmss (map ind_rule (dnames ~~ inducts))) |
1099 |> Sign.parent_path |> pair take_rews |
1135 |> Sign.parent_path |> pair take_rews |
1100 end; (* let *) |
1136 end; (* let *) |
1101 end; (* struct *) |
1137 end; (* struct *) |