src/HOL/BNF/BNF_Def.thy
changeset 51893 596baae88a88
parent 51836 4d6dcd51dd52
child 51909 eb3169abcbd5
     1.1 --- a/src/HOL/BNF/BNF_Def.thy	Tue May 07 11:27:29 2013 +0200
     1.2 +++ b/src/HOL/BNF/BNF_Def.thy	Tue May 07 14:22:54 2013 +0200
     1.3 @@ -21,10 +21,18 @@
     1.4  "R1 ^-1 \<subseteq> R2 ^-1 \<longleftrightarrow> R1 \<subseteq> R2"
     1.5  unfolding converse_def by auto
     1.6  
     1.7 +lemma conversep_mono:
     1.8 +"R1 ^--1 \<le> R2 ^--1 \<longleftrightarrow> R1 \<le> R2"
     1.9 +unfolding conversep.simps by auto
    1.10 +
    1.11  lemma converse_shift:
    1.12  "R1 \<subseteq> R2 ^-1 \<Longrightarrow> R1 ^-1 \<subseteq> R2"
    1.13  unfolding converse_def by auto
    1.14  
    1.15 +lemma conversep_shift:
    1.16 +"R1 \<le> R2 ^--1 \<Longrightarrow> R1 ^--1 \<le> R2"
    1.17 +unfolding conversep.simps by auto
    1.18 +
    1.19  definition convol ("<_ , _>") where
    1.20  "<f , g> \<equiv> %a. (f a, g a)"
    1.21  
    1.22 @@ -42,6 +50,10 @@
    1.23  "\<lbrakk>f x = f' x; g x = g' x; P x\<rbrakk> \<Longrightarrow> <f , g> x \<in> {(f' a, g' a) |a. P a}"
    1.24  unfolding convol_def by auto
    1.25  
    1.26 +lemma convol_mem_GrpI:
    1.27 +"\<lbrakk>g x = g' x; x \<in> A\<rbrakk> \<Longrightarrow> <id , g> x \<in> (Collect (split (Grp A g)))"
    1.28 +unfolding convol_def Grp_def by auto
    1.29 +
    1.30  definition csquare where
    1.31  "csquare A f1 f2 p1 p2 \<longleftrightarrow> (\<forall> a \<in> A. f1 (p1 a) = f2 (p2 a))"
    1.32  
    1.33 @@ -91,48 +103,111 @@
    1.34  lemma Id_alt: "Id = Gr UNIV id"
    1.35  unfolding Gr_def by auto
    1.36  
    1.37 +lemma eq_alt: "op = = Grp UNIV id"
    1.38 +unfolding Grp_def by auto
    1.39 +
    1.40 +lemma leq_conversepI: "R = op = \<Longrightarrow> R \<le> R^--1"
    1.41 +  by auto
    1.42 +
    1.43 +lemma eq_OOI: "R = op = \<Longrightarrow> R = R OO R"
    1.44 +  by auto
    1.45 +
    1.46  lemma Gr_UNIV_id: "f = id \<Longrightarrow> (Gr UNIV f)^-1 O Gr UNIV f = Gr UNIV f"
    1.47  unfolding Gr_def by auto
    1.48  
    1.49 +lemma Grp_UNIV_id: "f = id \<Longrightarrow> (Grp UNIV f)^--1 OO Grp UNIV f = Grp UNIV f"
    1.50 +unfolding Grp_def by auto
    1.51 +
    1.52 +lemma Grp_UNIV_idI: "x = y \<Longrightarrow> Grp UNIV id x y"
    1.53 +unfolding Grp_def by auto
    1.54 +
    1.55  lemma Gr_mono: "A \<subseteq> B \<Longrightarrow> Gr A f \<subseteq> Gr B f"
    1.56  unfolding Gr_def by auto
    1.57  
    1.58 +lemma Grp_mono: "A \<le> B \<Longrightarrow> Grp A f \<le> Grp B f"
    1.59 +unfolding Grp_def by auto
    1.60 +
    1.61 +lemma GrpI: "\<lbrakk>f x = y; x \<in> A\<rbrakk> \<Longrightarrow> Grp A f x y"
    1.62 +unfolding Grp_def by auto
    1.63 +
    1.64 +lemma GrpE: "Grp A f x y \<Longrightarrow> (\<lbrakk>f x = y; x \<in> A\<rbrakk> \<Longrightarrow> R) \<Longrightarrow> R"
    1.65 +unfolding Grp_def by auto
    1.66 +
    1.67 +lemma Collect_split_Grp_eqD: "z \<in> Collect (split (Grp A f)) \<Longrightarrow> (f \<circ> fst) z = snd z"
    1.68 +unfolding Grp_def o_def by auto
    1.69 +
    1.70 +lemma Collect_split_Grp_inD: "z \<in> Collect (split (Grp A f)) \<Longrightarrow> fst z \<in> A"
    1.71 +unfolding Grp_def o_def by auto
    1.72 +
    1.73  lemma wpull_Gr:
    1.74  "wpull (Gr A f) A (f ` A) f id fst snd"
    1.75  unfolding wpull_def Gr_def by auto
    1.76  
    1.77 +lemma wpull_Grp:
    1.78 +"wpull (Collect (split (Grp A f))) A (f ` A) f id fst snd"
    1.79 +unfolding wpull_def Grp_def by auto
    1.80 +
    1.81  definition "pick_middle P Q a c = (SOME b. (a,b) \<in> P \<and> (b,c) \<in> Q)"
    1.82  
    1.83 +definition "pick_middlep P Q a c = (SOME b. P a b \<and> Q b c)"
    1.84 +
    1.85  lemma pick_middle:
    1.86  "(a,c) \<in> P O Q \<Longrightarrow> (a, pick_middle P Q a c) \<in> P \<and> (pick_middle P Q a c, c) \<in> Q"
    1.87 -unfolding pick_middle_def apply(rule someI_ex)
    1.88 -using assms unfolding relcomp_def by auto
    1.89 +unfolding pick_middle_def apply(rule someI_ex) by auto
    1.90 +
    1.91 +lemma pick_middlep:
    1.92 +"(P OO Q) a c \<Longrightarrow> P a (pick_middlep P Q a c) \<and> Q (pick_middlep P Q a c) c"
    1.93 +unfolding pick_middlep_def apply(rule someI_ex) by auto
    1.94  
    1.95  definition fstO where "fstO P Q ac = (fst ac, pick_middle P Q (fst ac) (snd ac))"
    1.96  definition sndO where "sndO P Q ac = (pick_middle P Q (fst ac) (snd ac), snd ac)"
    1.97  
    1.98 +definition fstOp where "fstOp P Q ac = (fst ac, pick_middlep P Q (fst ac) (snd ac))"
    1.99 +definition sndOp where "sndOp P Q ac = (pick_middlep P Q (fst ac) (snd ac), (snd ac))"
   1.100 +
   1.101  lemma fstO_in: "ac \<in> P O Q \<Longrightarrow> fstO P Q ac \<in> P"
   1.102 -unfolding fstO_def
   1.103 -by (subst (asm) surjective_pairing) (rule pick_middle[THEN conjunct1])
   1.104 +unfolding fstO_def by (subst (asm) surjective_pairing) (rule pick_middle[THEN conjunct1])
   1.105 +
   1.106 +lemma fstOp_in: "ac \<in> Collect (split (P OO Q)) \<Longrightarrow> fstOp P Q ac \<in> Collect (split P)"
   1.107 +unfolding fstOp_def mem_Collect_eq
   1.108 +by (subst (asm) surjective_pairing, unfold prod.cases) (erule pick_middlep[THEN conjunct1])
   1.109  
   1.110  lemma fst_fstO: "fst bc = (fst \<circ> fstO P Q) bc"
   1.111  unfolding comp_def fstO_def by simp
   1.112  
   1.113 +lemma fst_fstOp: "fst bc = (fst \<circ> fstOp P Q) bc"
   1.114 +unfolding comp_def fstOp_def by simp
   1.115 +
   1.116  lemma snd_sndO: "snd bc = (snd \<circ> sndO P Q) bc"
   1.117  unfolding comp_def sndO_def by simp
   1.118  
   1.119 +lemma snd_sndOp: "snd bc = (snd \<circ> sndOp P Q) bc"
   1.120 +unfolding comp_def sndOp_def by simp
   1.121 +
   1.122  lemma sndO_in: "ac \<in> P O Q \<Longrightarrow> sndO P Q ac \<in> Q"
   1.123  unfolding sndO_def
   1.124  by (subst (asm) surjective_pairing) (rule pick_middle[THEN conjunct2])
   1.125  
   1.126 +lemma sndOp_in: "ac \<in> Collect (split (P OO Q)) \<Longrightarrow> sndOp P Q ac \<in> Collect (split Q)"
   1.127 +unfolding sndOp_def mem_Collect_eq
   1.128 +by (subst (asm) surjective_pairing, unfold prod.cases) (erule pick_middlep[THEN conjunct2])
   1.129 +
   1.130  lemma csquare_fstO_sndO:
   1.131  "csquare (P O Q) snd fst (fstO P Q) (sndO P Q)"
   1.132  unfolding csquare_def fstO_def sndO_def using pick_middle by simp
   1.133  
   1.134 +lemma csquare_fstOp_sndOp:
   1.135 +"csquare (Collect (split (P OO Q))) snd fst (fstOp P Q) (sndOp P Q)"
   1.136 +unfolding csquare_def fstOp_def sndOp_def using pick_middlep by simp
   1.137 +
   1.138  lemma wppull_fstO_sndO:
   1.139  shows "wppull (P O Q) P Q snd fst fst snd (fstO P Q) (sndO P Q)"
   1.140  using pick_middle unfolding wppull_def fstO_def sndO_def relcomp_def by auto
   1.141  
   1.142 +lemma wppull_fstOp_sndOp:
   1.143 +shows "wppull (Collect (split (P OO Q))) (Collect (split P)) (Collect (split Q)) snd fst fst snd (fstOp P Q) (sndOp P Q)"
   1.144 +using pick_middlep unfolding wppull_def fstOp_def sndOp_def relcompp.simps by auto
   1.145 +
   1.146  lemma snd_fst_flip: "snd xy = (fst o (%(x, y). (y, x))) xy"
   1.147  by (simp split: prod.split)
   1.148  
   1.149 @@ -142,11 +217,17 @@
   1.150  lemma flip_rel: "A \<subseteq> (R ^-1) \<Longrightarrow> (%(x, y). (y, x)) ` A \<subseteq> R"
   1.151  by auto
   1.152  
   1.153 +lemma flip_pred: "A \<subseteq> Collect (split (R ^--1)) \<Longrightarrow> (%(x, y). (y, x)) ` A \<subseteq> Collect (split R)"
   1.154 +by auto
   1.155 +
   1.156  lemma pointfreeE: "f o g = f' o g' \<Longrightarrow> f (g x) = f' (g' x)"
   1.157  unfolding o_def fun_eq_iff by simp
   1.158  
   1.159 -lemma eqset_imp_iff_pair: "A = B \<Longrightarrow> (a, b) \<in> A \<longleftrightarrow> (a, b) \<in> B"
   1.160 -by (rule eqset_imp_iff)
   1.161 +lemma Collect_split_mono: "A \<le> B \<Longrightarrow> Collect (split A) \<subseteq> Collect (split B)"
   1.162 +  by auto
   1.163 +
   1.164 +lemma predicate2_cong: "A = B \<Longrightarrow> A a b \<longleftrightarrow> B a b"
   1.165 +by metis
   1.166  
   1.167  lemma fun_cong_pair: "f = g \<Longrightarrow> f {(a, b). R a b} = g {(a, b). R a b}"
   1.168  by (rule fun_cong)
   1.169 @@ -161,4 +242,5 @@
   1.170  ML_file "Tools/bnf_def_tactics.ML"
   1.171  ML_file "Tools/bnf_def.ML"
   1.172  
   1.173 +
   1.174  end