Skip to content

Commit 48aa67c

Browse files
committed
Cleared up most of the remaining linter warnings
1 parent f679dd2 commit 48aa67c

6 files changed

Lines changed: 46 additions & 28 deletions

File tree

Finite_Fun.thy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
section \<open> Finite Functions \<close>
22

33
theory Finite_Fun
4-
imports Map_Extra Partial_Fun
4+
imports Partial_Fun
55
begin
66

77
subsection \<open> Finite function type and operations \<close>
88

99
typedef ('a, 'b) ffun = "{f :: ('a, 'b) pfun. finite(pdom(f))}"
1010
morphisms pfun_of Abs_pfun
11-
by (rule_tac x="{}\<^sub>p" in exI, auto)
11+
using infinite_imp_nonempty by auto
1212

1313
type_notation ffun (infixr "\<Zffun>" 1)
1414

Finite_Inj.thy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ begin
66

77
typedef ('a, 'b) finj = "{f :: 'a \<Zpinj> 'b. finite(pidom(f))}"
88
morphisms pinj_of_finj finj_of_pinj
9-
by (rule_tac x="{}\<^sub>\<rho>" in exI, simp)
9+
by (metis CollectI infinite_imp_nonempty pidom_empty)
1010

1111
setup_lifting type_definition_ffun
1212
setup_lifting type_definition_finj

Partial_Fun.thy

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ imports "Optics.Optics" Map_Extra "HOL-Library.Mapping"
55
begin
66

77
no_notation "Stream.stream.SCons" (infixr \<open>##\<close> 65)
8+
no_notation Order.le (infixl \<open>\<sqsubseteq>\<index>\<close> 50)
9+
no_notation Order.top (\<open>\<top>\<index>\<close>)
10+
no_notation Order.bottom (\<open>\<bottom>\<index>\<close>)
811

912
text \<open> I'm not completely satisfied with partial functions as provided by Map.thy, since they don't
1013
have a unique type and so we can't instantiate classes, make use of adhoc-overloading
@@ -314,8 +317,10 @@ lemma pfun_minus_common_subset:
314317

315318
lemma pfun_minus_override:
316319
"pdom(f) \<inter> pdom(g) = {} \<Longrightarrow> (f \<oplus> g) - g = f"
317-
by (transfer, simp add: map_add_def map_minus_def option.case_eq_if, rule ext, safe, simp)
318-
(metis Int_commute domIff insert_disjoint(1) insert_dom)
320+
apply (transfer)
321+
apply (simp add: map_add_def map_minus_def option.case_eq_if fun_eq_iff)
322+
apply (metis disjoint_iff domI domIff)
323+
done
319324

320325
lemma pfun_override_pos: "x \<oplus> y = {}\<^sub>p \<Longrightarrow> x = {}\<^sub>p"
321326
by (transfer, simp)
@@ -697,7 +702,7 @@ lemma pfun_inj_dres: "pfun_inj f \<Longrightarrow> pfun_inj (A \<lhd>\<^sub>p f)
697702
by (transfer, auto simp add: inj_on_def)
698703

699704
lemma pfun_inj_rres: "pfun_inj f \<Longrightarrow> pfun_inj (f \<rhd>\<^sub>p A)"
700-
by (transfer, simp add: inj_on_def ran_restrict_map_def, safe, simp, metis domI option.simps(3))
705+
by (transfer, metis dom_map_inv inj_map_inv map_inv_dom_res map_inv_map_inv map_inv_ran_res ran_ran_restrict restrict_map_inj_on)
701706

702707
lemma pfun_inj_comp: "\<lbrakk> pfun_inj f; pfun_inj g \<rbrakk> \<Longrightarrow> pfun_inj (f \<circ>\<^sub>p g)"
703708
by (transfer, auto simp add: inj_on_def map_comp_def option.case_eq_if dom_def)
@@ -826,11 +831,7 @@ lemma pran_res_alt_def: "f \<rhd>\<^sub>p A = pId_on A \<circ>\<^sub>p f"
826831
by (transfer, rule ext, auto simp add: ran_restrict_map_def)
827832

828833
lemma pran_res_override: "(f \<oplus> g) \<rhd>\<^sub>p A \<subseteq>\<^sub>p (f \<rhd>\<^sub>p A) \<oplus> (g \<rhd>\<^sub>p A)"
829-
apply (transfer, simp add: map_add_def ran_restrict_map_def map_le_def, safe)
830-
apply (rename_tac f g A a y x)
831-
apply (case_tac "g a")
832-
apply (auto)
833-
done
834+
by (transfer, auto simp add: map_add_def ran_restrict_map_def map_le_def option.case_eq_if)
834835

835836
lemma pcomp_ranres [simp]: "(f \<circ>\<^sub>p g) \<rhd>\<^sub>p A = (f \<rhd>\<^sub>p A) \<circ>\<^sub>p g"
836837
by (simp add: pfun_comp_assoc pran_res_alt_def)
@@ -1065,19 +1066,33 @@ lemma pfun_graph_list_pfun: "pfun_graph (list_pfun xs) = (\<lambda> i. (i, xs !
10651066
by (simp add: list_pfun_def pfun_graph_pabs, auto)
10661067

10671068
lemma range_list_pfun:
1068-
"range list_pfun = {f. \<exists> i. pdom(f) = {1..i}}"
1069-
apply (simp add: list_pfun_def pabs_def)
1070-
apply (transfer, safe, simp_all)
1071-
apply (rename_tac xs)
1072-
apply (rule_tac x="length xs" in exI, auto simp add: dom_def)[1]
1073-
apply (simp add: image_def)
1074-
apply (rename_tac f i)
1075-
apply (rule_tac x="map (the \<circ> f \<circ> nat) [1..i]" in exI)
1076-
apply (simp add: fun_eq_iff restrict_map_def, safe, simp_all)
1077-
apply (metis Suc_le_mono Suc_pred atLeastAtMost_iff domIff le0 option.exhaust_sel)
1078-
apply (metis One_nat_def atLeastAtMost_iff domIff le_zero_eq zero_neq_one)
1079-
apply (metis atLeastAtMost_iff domIff)
1080-
done
1069+
"range list_pfun = {f :: nat \<Zpfun> 'a. \<exists> i. pdom(f) = {1..i}}"
1070+
proof (rule set_eqI, rule iffI)
1071+
fix f :: "nat \<Zpfun> 'a"
1072+
assume "f \<in> range list_pfun"
1073+
thus "f \<in> {f. \<exists>i. pdom f = {1..i}}"
1074+
by auto
1075+
next
1076+
fix f :: "nat \<Zpfun> 'a"
1077+
assume "f \<in> {f. \<exists>i. pdom f = {1..i}}"
1078+
thus "f \<in> range list_pfun"
1079+
proof (unfold list_pfun_def pabs_def image_def, transfer)
1080+
fix f :: "nat \<Rightarrow> 'a option"
1081+
assume "f \<in> {f. \<exists>i. dom f = {1..i}}"
1082+
then obtain i where i:"dom f = {1..i}"
1083+
by blast
1084+
hence 1: "\<And>x. dom f = {Suc 0..i} \<Longrightarrow> 0 < x \<Longrightarrow> x \<le> i \<Longrightarrow> f x = Some (the (f x))"
1085+
by (metis Suc_leI atLeastAtMost_iff domIff option.exhaust_sel)
1086+
with i have 2:"f 0 = None"
1087+
using atLeastAtMost_iff not_one_le_zero by blast
1088+
from i 1 2 have f: "f = (\<lambda>xa. Some (map (the \<circ> f \<circ> nat) [1..int i] ! (xa - Suc 0))) |` {ia. 0 < ia \<and> ia \<le> length (map (the \<circ> f \<circ> nat) [1..int i])}"
1089+
by (auto simp add: fun_eq_iff restrict_map_def)
1090+
have 3: "(\<lambda>xa. Some (map (the \<circ> f \<circ> nat) [1..int i] ! (xa - Suc 0))) |` {ia. 0 < ia \<and> ia \<le> length (map (the \<circ> f \<circ> nat) [1..int i])} \<in> {y. \<exists>x\<in>UNIV. y = (\<lambda>xa. if xa \<in> UNIV then Some (x ! (xa - 1)) else None) |` (UNIV \<inter> {i. 0 < i \<and> i \<le> length x})}"
1091+
by (auto simp add: fun_eq_iff restrict_map_def)
1092+
show "f \<in> {y. \<exists>x\<in>UNIV. y = (\<lambda>xa. if xa \<in> UNIV then Some (x ! (xa - 1)) else None) |` (UNIV \<inter> {i. 0 < i \<and> i \<le> length x})}"
1093+
using "3" f by auto
1094+
qed
1095+
qed
10811096

10821097
lemma list_pfun_le_iff_prefix [simp]: "list_pfun xs \<le> list_pfun ys \<longleftrightarrow> xs \<le> ys"
10831098
apply (simp add: pfun_le_iff, safe, simp_all add: pfun_app_list_pfun list_le_prefix_iff)

Positive.thy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ begin
99
subsection \<open> Type Definition \<close>
1010

1111
typedef (overloaded) 'a::"{zero, linorder}" pos = "{x::'a. x \<ge> 0}"
12-
apply (rule_tac x = "0" in exI)
13-
apply (clarsimp)
14-
done
12+
by blast
1513

1614
syntax
1715
"_type_pos" :: "type \<Rightarrow> type" ("_\<^sup>+" [999] 999)

Relation_Lib.thy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ text \<open> This theory marks the boundary between reusable library utilities a
1414
lemma if_eqE [elim!]: "\<lbrakk> (if b then e else f) = v; \<lbrakk> b; e = v \<rbrakk> \<Longrightarrow> P; \<lbrakk> \<not> b; f = v \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
1515
by (cases b, auto)
1616

17+
no_notation Order.le (infixl \<open>\<sqsubseteq>\<index>\<close> 50)
18+
no_notation Order.lless (infixl \<open>\<sqsubset>\<index>\<close> 50)
19+
no_notation Order.top (\<open>\<top>\<index>\<close>)
20+
no_notation Order.bottom (\<open>\<bottom>\<index>\<close>)
21+
1722
bundle Z_Type_Syntax
1823
begin
1924

Total_Fun.thy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ text \<open> It may seem a little strange to create this, given we already have
1111

1212
typedef ('a, 'b) tfun = "{f :: 'a \<Zpfun> 'b. pdom(f) = UNIV}"
1313
morphisms pfun_of_tfun Abs_tfun
14-
by (rule_tac x="pfun_entries UNIV undefined" in exI, simp)
14+
by (meson mem_Collect_eq pdom_pfun_entries)
1515

1616
type_notation tfun (infixr "\<Rightarrow>\<^sub>t" 0)
1717

0 commit comments

Comments
 (0)