@@ -117,10 +117,7 @@ lemma map_le_graph: "f \<subseteq>\<^sub>m g \<longleftrightarrow> map_graph f \
117117 by ( force simp add : map_le_def map_graph_def )
118118
119119lemma map_graph_comp : "map_graph (g \<circ>\<^sub>m f) = (map_graph f) O (map_graph g)"
120- apply ( simp add : map_comp_def map_graph_def relcomp_unfold , safe )
121- apply ( rename_tac a b )
122- apply ( case_tac "f a" , auto )
123- done
120+ by ( metis graph_def graph_map_comp map_graph_def )
124121
125122lemma rel_comp_map : "R O map_graph f = (\<lambda> p. (fst p, the (f (snd p)))) ` (R \<rhd>\<^sub>r dom(f))"
126123 by ( force simp add : map_graph_def relcomp_unfold rel_ranres_def image_def dom_def )
@@ -164,15 +161,24 @@ lemma dom_preimage: "dom (m \<circ>\<^sub>m f) = preimage f (dom m)"
164161 apply ( metis map_comp_def option.case_eq_if option.distinct ( 1 ))
165162 done
166163
164+
165+
167166lemma countable_preimage :
168- "\<lbrakk> countable A; inj_on f (preimage f A) \<rbrakk> \<Longrightarrow> countable (preimage f A)"
169- apply ( simp add : countable_def , safe )
170- apply ( rename_tac g )
171- apply ( rule_tac x = "g \<circ> the \<circ> f" in exI )
172- apply ( rule inj_onI )
173- apply ( drule inj_onD )
174- apply ( auto simp add : preimage_def inj_onD )
175- done
167+ assumes "countable A" "inj_on f (preimage f A)"
168+ shows "countable (preimage f A)"
169+ proof -
170+ obtain g :: "'a \<Rightarrow> nat" where g : "inj_on g A"
171+ using assms ( 1 ) by blast
172+ have "inj_on (g \<circ> the \<circ> f) (preimage f A)"
173+ proof ( rule inj_onI )
174+ fix x y
175+ assume "x \<in> preimage f A" "y \<in> preimage f A" "(g \<circ> the \<circ> f) x = (g \<circ> the \<circ> f) y"
176+ with assms g show "x = y"
177+ unfolding preimage_def by ( metis ( lifting ) comp_apply domIff inj_onD mem_Collect_eq option.expand )
178+ qed
179+ thus ?thesis
180+ by ( simp add : countableI )
181+ qed
176182
177183subsection \<open> Minus operation for maps \<close>
178184
@@ -210,14 +216,14 @@ text \<open> Create some extra intro/elim rules to help dealing with proof about
210216
211217lemma option_bindSomeE [ elim !]:
212218 "\<lbrakk> X >>= F = Some(v); \<And> x. \<lbrakk> X = Some(x); F(x) = Some(v) \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
213- by ( case_tac X , auto )
219+ by ( cases X , auto )
214220
215221lemma option_bindSomeI [ intro ]:
216222 "\<lbrakk> X = Some(x); F(x) = Some(y) \<rbrakk> \<Longrightarrow> X >>= F = Some(y)"
217223 by ( simp )
218224
219225lemma ifSomeE [ elim ]: "\<lbrakk> (if c then Some(x) else None) = Some(y); \<lbrakk> c; x = y \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
220- by ( case_tac c , auto )
226+ by ( cases c , auto )
221227
222228subsection \<open> Range Restriction \<close>
223229
@@ -233,13 +239,20 @@ lemma ran_restrict_empty [simp]: "f\<upharpoonleft>\<^bsub>{}\<^esub> = Map.empt
233239 by ( simp add : ran_restrict_map_def )
234240
235241lemma ran_restrict_ran [ simp ]: "f\<upharpoonleft>\<^bsub>ran(f) \<^esub> = f"
236- apply ( simp add : ran_restrict_map_def ran_def )
237- apply ( rule ext )
238- apply ( case_tac "f(x)" , auto )
239- done
242+ proof
243+ fix x
244+ show "(f\<upharpoonleft>\<^bsub>ran(f)\<^esub>) x = f x"
245+ proof ( cases "f(x)" )
246+ case None
247+ then show ?thesis by ( simp add : ran_restrict_map_def ran_def )
248+ next
249+ case ( Some a )
250+ then show ?thesis by ( auto simp add : ran_restrict_map_def ran_def )
251+ qed
252+ qed
240253
241254lemma ran_ran_restrict [ simp ]: "ran(f\<upharpoonleft>\<^bsub>B\<^esub>) = ran(f) \<inter> B"
242- by ( auto intro !: option_bindSomeI simp add : ran_restrict_map_def ran_def )
255+ by ( force simp add : ran_restrict_map_def ran_def )
243256
244257lemma dom_ran_restrict : "dom(f\<upharpoonleft>\<^bsub>B\<^esub>) \<subseteq> dom(f)"
245258 by ( auto simp add : ran_restrict_map_def dom_def )
@@ -255,11 +268,17 @@ lemma map_dres_rres_commute: "f\<upharpoonleft>\<^bsub>B\<^esub> |` A = (f |` A)
255268 by ( auto simp add : restrict_map_def ran_restrict_map_def )
256269
257270lemma ran_restrict_map_twice [ simp ]: "(f\<upharpoonleft>\<^bsub>A\<^esub>)\<upharpoonleft>\<^bsub>B\<^esub> = f\<upharpoonleft>\<^bsub>(A \<inter> B)\<^esub>"
258- apply ( simp add : ran_restrict_map_def fun_eq_iff option.case_eq_if , safe )
259- apply ( rename_tac x )
260- apply ( case_tac "f x" )
261- apply ( auto )
262- done
271+ proof
272+ fix x
273+ show "((f\<upharpoonleft>\<^bsub>A\<^esub>)\<upharpoonleft>\<^bsub>B\<^esub>) x = (f\<upharpoonleft>\<^bsub>(A \<inter> B)\<^esub>) x"
274+ proof ( cases "f x" )
275+ case None
276+ then show ?thesis by ( simp add : ran_restrict_map_def )
277+ next
278+ case ( Some a )
279+ then show ?thesis by ( simp add : ran_restrict_map_def fun_eq_iff option.case_eq_if )
280+ qed
281+ qed
263282
264283lemma dom_left_map_add [ simp ]: "x \<in> dom g \<Longrightarrow> (f ++ g) x = g x"
265284 by ( auto simp add : map_add_def dom_def )
@@ -328,14 +347,8 @@ lemma dom_map_inv [simp]:
328347lemma ran_map_inv [ simp ]:
329348 "inj_on f (dom f) \<Longrightarrow> ran (map_inv f) = dom f"
330349 apply ( simp add : map_inv_def ran_def , safe )
331- apply ( rename_tac a b )
332- apply ( rule_tac x = "a" in exI )
333- apply ( force intro : someI )
334- apply ( rename_tac x y )
335- apply ( rule_tac x = "y" in exI )
336- apply ( safe )
337- apply ( rule some_equality , simp_all )
338- apply ( auto simp add : inj_on_def dom_def )
350+ apply ( metis ( mono_tags , lifting ) verit_sko_ex' )
351+ apply ( metis ( mono_tags , lifting ) domI domIff map_inv_def map_inv_f_f option.inject )
339352 done
340353
341354lemma dom_image_ran : "f ` dom f = Some ` ran f"
@@ -344,11 +357,7 @@ lemma dom_image_ran: "f ` dom f = Some ` ran f"
344357lemma inj_map_inv [ intro ]:
345358 "inj_on f (dom f) \<Longrightarrow> inj_on (map_inv f) (ran f)"
346359 apply ( simp add : map_inv_def inj_on_def dom_def ran_def , safe )
347- apply ( rename_tac x y u v )
348- apply ( frule_tac P = "\<lambda> xa. f xa = Some x" in some_equality )
349- apply ( safe )
350- apply force
351- apply ( metis ( mono_tags ) option.sel someI )
360+ apply ( metis ( mono_tags , lifting ) option.sel someI_ex )
352361 done
353362
354363lemma inj_map_bij : "inj_on f (dom f) \<Longrightarrow> bij_betw f (dom f) (Some ` ran f)"
@@ -363,59 +372,53 @@ proof -
363372 by auto
364373
365374 thus ?thesis
366- apply ( rule_tac ext )
367- apply ( rename_tac x )
368- apply ( case_tac "\<exists> y. map_inv f y = Some x" )
369- apply ( metis assms domD dom_map_inv map_inv_f_f ranI ran_map_inv )
370- apply ( metis assms domIff map_inv_def map_inv_f_f option.collapse ran_map_inv )
371- done
375+ by ( metis ( no_types , lifting ) ext assms domIff dom_map_inv map_inv_f_f option.collapse
376+ ran_map_inv )
372377qed
373378
374379lemma map_self_adjoin_complete [ intro ]:
375380 assumes "dom f \<inter> ran f = {}" "inj_on f (dom f)"
376381 shows "inj_on (map_inv f ++ f) (dom f \<union> ran f)"
377- apply ( rule inj_onI )
378- apply ( insert assms )
379- apply ( rename_tac x y )
380- apply ( case_tac "x \<in> dom f" )
381- apply ( simp )
382- apply ( case_tac "y \<in> dom f" )
383- apply ( simp add : inj_on_def )
384- apply ( case_tac "y \<in> ran f" )
385- apply ( subgoal_tac "y \<in> dom (map_inv f)" )
386- apply ( simp )
387- apply ( metis Int_iff domD empty_iff ranI ran_map_inv )
388- apply ( simp )
389- apply ( simp )
390- apply ( simp )
391- apply ( case_tac "y \<in> dom f" )
392- apply ( simp )
393- apply ( case_tac "y \<in> ran f" )
394- apply ( subgoal_tac "y \<in> dom (map_inv f)" )
395- apply ( simp )
396- apply ( metis Int_iff empty_iff )
397- apply ( simp )
398- apply ( metis Int_iff domD empty_iff ranI ran_map_inv )
399- apply ( simp )
400- apply ( metis ( lifting ) inj_map_inv inj_on_contraD )
401- done
382+ proof ( rule inj_onI )
383+ fix x y
384+ assume x : "x \<in> dom f \<union> ran f" and y : "y \<in> dom f \<union> ran f"
385+ and f : "(map_inv f ++ f) x = (map_inv f ++ f) y"
386+
387+ show "x = y"
388+ proof ( cases "x \<in> dom f" )
389+ case True
390+ then show ?thesis
391+ by ( metis assms ( 1 , 2 ) disjoint_iff_not_equal domD dom_left_map_add f inj_on_def
392+ map_add_dom_app_simps ( 3 ) ranI ran_map_inv )
393+ next
394+ case False
395+ then show ?thesis
396+ by ( metis ( full_types ) UnE assms ( 1 , 2 ) disjoint_iff domIff dom_left_map_add dom_map_inv
397+ f inj_map_inv inj_on_def map_add_dom_app_simps ( 3 ) ran_map_inv ran_restrict_alt_def
398+ ran_restrict_ran x )
399+ qed
400+ qed
402401
403402lemma inj_completed_map [ intro ]:
404- "\<lbrakk> dom f = ran f; inj_on f (dom f) \<rbrakk> \<Longrightarrow> inj (Some ++ f)"
405- apply ( drule inj_map_bij )
406- apply ( simp add : bij_betw_def )
407- apply safe
408- apply ( simp add : inj_on_def )
409- apply safe
410- apply ( rename_tac x y )
411- apply ( case_tac "x \<in> dom f" )
412- apply ( simp )
413- apply ( case_tac "y \<in> dom f" )
414- apply ( simp )
415- apply ( simp add : ran_def )
416- apply ( case_tac "y \<in> dom f" )
417- apply ( auto intro : ranI )
418- done
403+ assumes "dom f = ran f" "inj_on f (dom f)"
404+ shows "inj (Some ++ f)"
405+ proof ( rule injI )
406+ fix x y
407+ assume f : "(Some ++ f) x = (Some ++ f) y"
408+ have bb : "bij_betw f (dom f) (Some ` ran f)"
409+ using assms ( 2 ) inj_map_bij by blast
410+ thus "x = y"
411+ proof ( cases "x \<in> dom f" )
412+ case True
413+ then show ?thesis
414+ by ( metis assms ( 1 , 2 ) f inj_on_contraD map_add_dom_app_simps ( 1 , 3 ) ranI )
415+ next
416+ case False
417+ then show ?thesis
418+ by ( metis assms ( 1 ) dom_left_map_add f map_add_dom_app_simps ( 3 ) option.inject
419+ ranI )
420+ qed
421+ qed
419422
420423lemma bij_completed_map [ intro ]:
421424 "\<lbrakk> dom f = ran f; inj_on f (dom f) \<rbrakk> \<Longrightarrow>
0 commit comments