167 and Basis1 Basis2 |
167 and Basis1 Basis2 |
168 |
168 |
169 |
169 |
170 subsection \<open>Local Typedef for Subspace\<close> |
170 subsection \<open>Local Typedef for Subspace\<close> |
171 |
171 |
172 locale local_typedef_ab_group_add = local_typedef S s + |
|
173 ab_group_add_on_with S |
|
174 for S ::"'b set" and s::"'s itself" |
|
175 begin |
|
176 |
|
177 lemma mem_minus_lt: "x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> mns x y \<in> S" |
|
178 using ab_diff_conv_add_uminus[of x y] add_mem[of x "um y"] uminus_mem[of y] |
|
179 by auto |
|
180 |
|
181 context includes lifting_syntax begin |
|
182 |
|
183 definition plus_S::"'s \<Rightarrow> 's \<Rightarrow> 's" where "plus_S = (rep ---> rep ---> Abs) pls" |
|
184 definition minus_S::"'s \<Rightarrow> 's \<Rightarrow> 's" where "minus_S = (rep ---> rep ---> Abs) mns" |
|
185 definition uminus_S::"'s \<Rightarrow> 's" where "uminus_S = (rep ---> Abs) um" |
|
186 definition zero_S::"'s" where "zero_S = Abs z" |
|
187 |
|
188 lemma plus_S_transfer[transfer_rule]: "(cr_S ===> cr_S ===> cr_S) pls plus_S" |
|
189 unfolding plus_S_def |
|
190 by (auto simp: cr_S_def add_mem intro!: rel_funI) |
|
191 |
|
192 lemma minus_S_transfer[transfer_rule]: "(cr_S ===> cr_S ===> cr_S) mns minus_S" |
|
193 unfolding minus_S_def |
|
194 by (auto simp: cr_S_def mem_minus_lt intro!: rel_funI) |
|
195 |
|
196 lemma uminus_S_transfer[transfer_rule]: "(cr_S ===> cr_S) um uminus_S" |
|
197 unfolding uminus_S_def |
|
198 by (auto simp: cr_S_def uminus_mem intro!: rel_funI) |
|
199 |
|
200 lemma zero_S_transfer[transfer_rule]: "cr_S z zero_S" |
|
201 unfolding zero_S_def |
|
202 by (auto simp: cr_S_def zero_mem intro!: rel_funI) |
|
203 |
|
204 end |
|
205 |
|
206 sublocale type: ab_group_add plus_S "zero_S::'s" minus_S uminus_S |
|
207 apply unfold_locales |
|
208 subgoal by transfer (rule add_assoc) |
|
209 subgoal by transfer (rule add_commute) |
|
210 subgoal by transfer (rule add_zero) |
|
211 subgoal by transfer (rule ab_left_minus) |
|
212 subgoal by transfer (rule ab_diff_conv_add_uminus) |
|
213 done |
|
214 |
|
215 context includes lifting_syntax begin |
|
216 |
|
217 lemma sum_transfer[transfer_rule]: |
|
218 "((A===>cr_S) ===> rel_set A ===> cr_S) (sum_with pls z) type.sum" |
|
219 if [transfer_rule]: "bi_unique A" |
|
220 proof (safe intro!: rel_funI) |
|
221 fix f g I J |
|
222 assume fg[transfer_rule]: "(A ===> cr_S) f g" and rel_set: "rel_set A I J" |
|
223 show "cr_S (sum_with pls z f I) (type.sum g J)" |
|
224 using rel_set |
|
225 proof (induction I arbitrary: J rule: infinite_finite_induct) |
|
226 case (infinite I) |
|
227 note [transfer_rule] = infinite.prems |
|
228 from infinite.hyps have "infinite J" by transfer |
|
229 with infinite.hyps show ?case |
|
230 by (simp add: zero_S_transfer sum_with_infinite) |
|
231 next |
|
232 case [transfer_rule]: empty |
|
233 have "J = {}" by transfer rule |
|
234 then show ?case by (simp add: zero_S_transfer) |
|
235 next |
|
236 case (insert x F) |
|
237 note [transfer_rule] = insert.prems |
|
238 have [simp]: "finite J" |
|
239 by transfer (simp add: insert.hyps) |
|
240 obtain y where [transfer_rule]: "A x y" and y: "y \<in> J" |
|
241 by (meson insert.prems insertI1 rel_setD1) |
|
242 define J' where "J' = J - {y}" |
|
243 have T_def: "J = insert y J'" |
|
244 by (auto simp: J'_def y) |
|
245 define sF where "sF = sum_with pls z f F" |
|
246 define sT where "sT = type.sum g J'" |
|
247 have [simp]: "y \<notin> J'" "finite J'" |
|
248 by (auto simp: y J'_def) |
|
249 have "rel_set A (insert x F - {x}) J'" |
|
250 unfolding J'_def |
|
251 by transfer_prover |
|
252 then have "rel_set A F J'" |
|
253 using insert.hyps |
|
254 by simp |
|
255 from insert.IH[OF this] have [transfer_rule]: "cr_S sF sT" by (auto simp: sF_def sT_def) |
|
256 have f_S: "f x \<in> S" "f ` F \<subseteq> S" |
|
257 using \<open>A x y\<close> fg insert.prems |
|
258 by (auto simp: rel_fun_def cr_S_def rel_set_def) |
|
259 have "cr_S (pls (f x) sF) (plus_S (g y) sT)" by transfer_prover |
|
260 then have "cr_S (sum_with pls z f (insert x F)) (type.sum g (insert y J'))" |
|
261 by (simp add: sum_with_insert insert.hyps type.sum.insert_remove sF_def[symmetric] |
|
262 sT_def[symmetric] f_S) |
|
263 then show ?case |
|
264 by (simp add: T_def) |
|
265 qed |
|
266 qed |
|
267 |
|
268 end |
|
269 |
|
270 end |
|
271 |
|
272 locale local_typedef_module_on = module_on S scale |
172 locale local_typedef_module_on = module_on S scale |
273 for S and scale::"'a::comm_ring_1\<Rightarrow>'b\<Rightarrow>'b::ab_group_add" and s::"'s itself" + |
173 for S and scale::"'a::comm_ring_1\<Rightarrow>'b\<Rightarrow>'b::ab_group_add" and s::"'s itself" + |
274 assumes Ex_type_definition_S: "\<exists>(Rep::'s \<Rightarrow> 'b) (Abs::'b \<Rightarrow> 's). type_definition Rep Abs S" |
174 assumes Ex_type_definition_S: "\<exists>(Rep::'s \<Rightarrow> 'b) (Abs::'b \<Rightarrow> 's). type_definition Rep Abs S" |
275 begin |
175 begin |
276 |
176 |
279 by (induction X rule: infinite_finite_induct) (auto intro!: mem_zero mem_add) |
179 by (induction X rule: infinite_finite_induct) (auto intro!: mem_zero mem_add) |
280 |
180 |
281 sublocale local_typedef S "TYPE('s)" |
181 sublocale local_typedef S "TYPE('s)" |
282 using Ex_type_definition_S by unfold_locales |
182 using Ex_type_definition_S by unfold_locales |
283 |
183 |
284 sublocale local_typedef_ab_group_add "(+)::'b\<Rightarrow>'b\<Rightarrow>'b" "0::'b" "(-)" uminus S "TYPE('s)" |
184 sublocale local_typedef_ab_group_add_on_with "(+)::'b\<Rightarrow>'b\<Rightarrow>'b" "0::'b" "(-)" uminus S "TYPE('s)" |
285 using mem_zero mem_add mem_scale[of _ "-1"] |
185 using mem_zero mem_add mem_scale[of _ "-1"] |
286 by unfold_locales (auto simp: scale_minus_left_on) |
186 by unfold_locales (auto simp: scale_minus_left_on) |
287 |
187 |
288 context includes lifting_syntax begin |
188 context includes lifting_syntax begin |
289 |
189 |