Skip to content

Commit e3baae1

Browse files
committed
Removed more linter issues
1 parent 1e2168c commit e3baae1

4 files changed

Lines changed: 101 additions & 99 deletions

File tree

Bounded_List.thy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ code_datatype bmake
3737

3838
lemma bmake_length_card:
3939
"blength (bmake TYPE('n::finite) xs) = (if length xs \<le> CARD('n) then length xs else CARD('n))"
40-
apply (simp add: blength_def bmake_def, auto)
41-
by (simp add: blist_of_list_inverse)+
40+
by (simp add: blength_def bmake_def, auto simp add: blist_of_list_inverse)
4241

4342
lemma blist_always_bounded:
4443
"length (list_of_blist (bl::'a blist['n::finite])) \<le> CARD('n)"
@@ -63,7 +62,12 @@ begin
6362
definition equal_blist :: "'a blist['b] \<Rightarrow> 'a blist['b] \<Rightarrow> bool" where
6463
"equal_blist m1 m2 \<longleftrightarrow> (list_of_blist m1 = list_of_blist m2)"
6564

66-
instance by (intro_classes, auto simp add: equal_blist_def, transfer, auto)
65+
instance proof
66+
fix x y :: "'a blist['b]"
67+
show "equal_class.equal x y = (x = y)"
68+
by (simp add: equal_blist_def, transfer, simp)
69+
qed
70+
6771
end
6872

6973
lemma list_of_blist_code [code]:

Countable_Set_Extra.thy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ lemma the_Some_image [simp]:
134134

135135
lemma CCollect_ext_Some [simp]:
136136
"CCollect_ext Some xs = CCollect xs"
137-
apply (case_tac "CCollect xs")
138-
apply (auto simp add:CCollect_ext_def)
139-
done
137+
by (cases "CCollect xs", auto simp add:CCollect_ext_def)
140138

141139
lift_definition list_of_cset :: "'a :: linorder cset \<Rightarrow> 'a list" is sorted_list_of_set .
142140

Infinite_Sequence.thy

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,9 @@ proof (rule transI, clarify)
132132
by (metis assms le_eq_less_or_eq le_less_trans nth_sinit transD)
133133
moreover from lt sinitm sinitn have "\<forall> j<i. sinit m xs!j = sinit m zs!j"
134134
by (metis less_le_trans less_trans nth_sinit)
135-
ultimately have "(sinit n xs, sinit n zs) \<in> lexord R" using sinitm(2) sinitn(2) lt
136-
apply (rule_tac lexord_intro_elems)
137-
apply (simp_all)
138-
apply (metis less_le_trans less_trans nth_sinit)
139-
done
135+
ultimately have "(sinit n xs, sinit n zs) \<in> lexord R"
136+
by (metis assms las(1,2) lexord_append lexord_sufI lexord_trans linorder_le_cases
137+
linorder_less_linear sinit_append_split sinit_len)
140138
thus ?thesis by auto
141139
next
142140
case False
@@ -145,11 +143,10 @@ proof (rule transI, clarify)
145143
by (metis less_trans nth_sinit)
146144
moreover from ge sinitm sinitn have "\<forall> k<j. sinit m xs!k = sinit m zs!k"
147145
by (metis dual_order.strict_trans nth_sinit)
148-
ultimately have "(sinit n xs, sinit n zs) \<in> lexord R" using sinitm(2) sinitn(2) ge
149-
apply (rule_tac lexord_intro_elems)
150-
apply (simp_all)
151-
apply (metis less_trans nth_sinit)
152-
done
146+
moreover hence "\<forall>k<j. sinit n xs ! k = sinit n zs ! k"
147+
by (metis dual_order.strict_trans ge nth_sinit sinitm(2) sinitn(2))
148+
ultimately have "(sinit n xs, sinit n zs) \<in> lexord R"
149+
by (metis lexord_intro_elems sinit_len sinitn(2))
153150
thus ?thesis by auto
154151
qed
155152
qed

Map_Extra.thy

Lines changed: 86 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -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

119119
lemma 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

125122
lemma 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+
167166
lemma 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

177183
subsection \<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

211217
lemma 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

215221
lemma option_bindSomeI [intro]:
216222
"\<lbrakk> X = Some(x); F(x) = Some(y) \<rbrakk> \<Longrightarrow> X >>= F = Some(y)"
217223
by (simp)
218224

219225
lemma 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

222228
subsection \<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

235241
lemma 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

241254
lemma 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

244257
lemma 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

257270
lemma 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

264283
lemma 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]:
328347
lemma 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

341354
lemma dom_image_ran: "f ` dom f = Some ` ran f"
@@ -344,11 +357,7 @@ lemma dom_image_ran: "f ` dom f = Some ` ran f"
344357
lemma 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

354363
lemma 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)
372377
qed
373378

374379
lemma 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

403402
lemma 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

420423
lemma bij_completed_map [intro]:
421424
"\<lbrakk> dom f = ran f; inj_on f (dom f) \<rbrakk> \<Longrightarrow>

0 commit comments

Comments
 (0)