src/ZF/pair.thy
changeset 76215 a642599ffdea
parent 76214 0c18df79b1c8
child 76216 9fc34f76b4e8
equal deleted inserted replaced
76214:0c18df79b1c8 76215:a642599ffdea
    27   fn _ => Quantifier1.rearrange_Ball
    27   fn _ => Quantifier1.rearrange_Ball
    28     (fn ctxt => unfold_tac ctxt @{thms Ball_def})
    28     (fn ctxt => unfold_tac ctxt @{thms Ball_def})
    29 \<close>
    29 \<close>
    30 
    30 
    31 
    31 
    32 (** Lemmas for showing that <a,b> uniquely determines a and b **)
    32 (** Lemmas for showing that \<langle>a,b\<rangle> uniquely determines a and b **)
    33 
    33 
    34 lemma singleton_eq_iff [iff]: "{a} = {b} \<longleftrightarrow> a=b"
    34 lemma singleton_eq_iff [iff]: "{a} = {b} \<longleftrightarrow> a=b"
    35 by (rule extension [THEN iff_trans], blast)
    35 by (rule extension [THEN iff_trans], blast)
    36 
    36 
    37 lemma doubleton_eq_iff: "{a,b} = {c,d} \<longleftrightarrow> (a=c \<and> b=d) | (a=d \<and> b=c)"
    37 lemma doubleton_eq_iff: "{a,b} = {c,d} \<longleftrightarrow> (a=c \<and> b=d) | (a=d \<and> b=c)"
    38 by (rule extension [THEN iff_trans], blast)
    38 by (rule extension [THEN iff_trans], blast)
    39 
    39 
    40 lemma Pair_iff [simp]: "<a,b> = <c,d> \<longleftrightarrow> a=c \<and> b=d"
    40 lemma Pair_iff [simp]: "\<langle>a,b\<rangle> = \<langle>c,d\<rangle> \<longleftrightarrow> a=c \<and> b=d"
    41 by (simp add: Pair_def doubleton_eq_iff, blast)
    41 by (simp add: Pair_def doubleton_eq_iff, blast)
    42 
    42 
    43 lemmas Pair_inject = Pair_iff [THEN iffD1, THEN conjE, elim!]
    43 lemmas Pair_inject = Pair_iff [THEN iffD1, THEN conjE, elim!]
    44 
    44 
    45 lemmas Pair_inject1 = Pair_iff [THEN iffD1, THEN conjunct1]
    45 lemmas Pair_inject1 = Pair_iff [THEN iffD1, THEN conjunct1]
    46 lemmas Pair_inject2 = Pair_iff [THEN iffD1, THEN conjunct2]
    46 lemmas Pair_inject2 = Pair_iff [THEN iffD1, THEN conjunct2]
    47 
    47 
    48 lemma Pair_not_0: "<a,b> \<noteq> 0"
    48 lemma Pair_not_0: "\<langle>a,b\<rangle> \<noteq> 0"
    49 apply (unfold Pair_def)
    49 apply (unfold Pair_def)
    50 apply (blast elim: equalityE)
    50 apply (blast elim: equalityE)
    51 done
    51 done
    52 
    52 
    53 lemmas Pair_neq_0 = Pair_not_0 [THEN notE, elim!]
    53 lemmas Pair_neq_0 = Pair_not_0 [THEN notE, elim!]
    54 
    54 
    55 declare sym [THEN Pair_neq_0, elim!]
    55 declare sym [THEN Pair_neq_0, elim!]
    56 
    56 
    57 lemma Pair_neq_fst: "<a,b>=a \<Longrightarrow> P"
    57 lemma Pair_neq_fst: "\<langle>a,b\<rangle>=a \<Longrightarrow> P"
    58 proof (unfold Pair_def)
    58 proof (unfold Pair_def)
    59   assume eq: "{{a, a}, {a, b}} = a"
    59   assume eq: "{{a, a}, {a, b}} = a"
    60   have  "{a, a} \<in> {{a, a}, {a, b}}" by (rule consI1)
    60   have  "{a, a} \<in> {{a, a}, {a, b}}" by (rule consI1)
    61   hence "{a, a} \<in> a" by (simp add: eq)
    61   hence "{a, a} \<in> a" by (simp add: eq)
    62   moreover have "a \<in> {a, a}" by (rule consI1)
    62   moreover have "a \<in> {a, a}" by (rule consI1)
    63   ultimately show "P" by (rule mem_asym)
    63   ultimately show "P" by (rule mem_asym)
    64 qed
    64 qed
    65 
    65 
    66 lemma Pair_neq_snd: "<a,b>=b \<Longrightarrow> P"
    66 lemma Pair_neq_snd: "\<langle>a,b\<rangle>=b \<Longrightarrow> P"
    67 proof (unfold Pair_def)
    67 proof (unfold Pair_def)
    68   assume eq: "{{a, a}, {a, b}} = b"
    68   assume eq: "{{a, a}, {a, b}} = b"
    69   have  "{a, b} \<in> {{a, a}, {a, b}}" by blast
    69   have  "{a, b} \<in> {{a, a}, {a, b}}" by blast
    70   hence "{a, b} \<in> b" by (simp add: eq)
    70   hence "{a, b} \<in> b" by (simp add: eq)
    71   moreover have "b \<in> {a, b}" by blast
    71   moreover have "b \<in> {a, b}" by blast
    75 
    75 
    76 subsection\<open>Sigma: Disjoint Union of a Family of Sets\<close>
    76 subsection\<open>Sigma: Disjoint Union of a Family of Sets\<close>
    77 
    77 
    78 text\<open>Generalizes Cartesian product\<close>
    78 text\<open>Generalizes Cartesian product\<close>
    79 
    79 
    80 lemma Sigma_iff [simp]: "<a,b>: Sigma(A,B) \<longleftrightarrow> a \<in> A \<and> b \<in> B(a)"
    80 lemma Sigma_iff [simp]: "\<langle>a,b\<rangle>: Sigma(A,B) \<longleftrightarrow> a \<in> A \<and> b \<in> B(a)"
    81 by (simp add: Sigma_def)
    81 by (simp add: Sigma_def)
    82 
    82 
    83 lemma SigmaI [TC,intro!]: "\<lbrakk>a \<in> A;  b \<in> B(a)\<rbrakk> \<Longrightarrow> <a,b> \<in> Sigma(A,B)"
    83 lemma SigmaI [TC,intro!]: "\<lbrakk>a \<in> A;  b \<in> B(a)\<rbrakk> \<Longrightarrow> \<langle>a,b\<rangle> \<in> Sigma(A,B)"
    84 by simp
    84 by simp
    85 
    85 
    86 lemmas SigmaD1 = Sigma_iff [THEN iffD1, THEN conjunct1]
    86 lemmas SigmaD1 = Sigma_iff [THEN iffD1, THEN conjunct1]
    87 lemmas SigmaD2 = Sigma_iff [THEN iffD1, THEN conjunct2]
    87 lemmas SigmaD2 = Sigma_iff [THEN iffD1, THEN conjunct2]
    88 
    88 
    89 (*The general elimination rule*)
    89 (*The general elimination rule*)
    90 lemma SigmaE [elim!]:
    90 lemma SigmaE [elim!]:
    91     "\<lbrakk>c \<in> Sigma(A,B);
    91     "\<lbrakk>c \<in> Sigma(A,B);
    92         \<And>x y.\<lbrakk>x \<in> A;  y \<in> B(x);  c=<x,y>\<rbrakk> \<Longrightarrow> P
    92         \<And>x y.\<lbrakk>x \<in> A;  y \<in> B(x);  c=\<langle>x,y\<rangle>\<rbrakk> \<Longrightarrow> P
    93 \<rbrakk> \<Longrightarrow> P"
    93 \<rbrakk> \<Longrightarrow> P"
    94 by (unfold Sigma_def, blast)
    94 by (unfold Sigma_def, blast)
    95 
    95 
    96 lemma SigmaE2 [elim!]:
    96 lemma SigmaE2 [elim!]:
    97     "\<lbrakk><a,b> \<in> Sigma(A,B);
    97     "\<lbrakk>\<langle>a,b\<rangle> \<in> Sigma(A,B);
    98         \<lbrakk>a \<in> A;  b \<in> B(a)\<rbrakk> \<Longrightarrow> P
    98         \<lbrakk>a \<in> A;  b \<in> B(a)\<rbrakk> \<Longrightarrow> P
    99 \<rbrakk> \<Longrightarrow> P"
    99 \<rbrakk> \<Longrightarrow> P"
   100 by (unfold Sigma_def, blast)
   100 by (unfold Sigma_def, blast)
   101 
   101 
   102 lemma Sigma_cong:
   102 lemma Sigma_cong:
   118 by blast
   118 by blast
   119 
   119 
   120 
   120 
   121 subsection\<open>Projections \<^term>\<open>fst\<close> and \<^term>\<open>snd\<close>\<close>
   121 subsection\<open>Projections \<^term>\<open>fst\<close> and \<^term>\<open>snd\<close>\<close>
   122 
   122 
   123 lemma fst_conv [simp]: "fst(<a,b>) = a"
   123 lemma fst_conv [simp]: "fst(\<langle>a,b\<rangle>) = a"
   124 by (simp add: fst_def)
   124 by (simp add: fst_def)
   125 
   125 
   126 lemma snd_conv [simp]: "snd(<a,b>) = b"
   126 lemma snd_conv [simp]: "snd(\<langle>a,b\<rangle>) = b"
   127 by (simp add: snd_def)
   127 by (simp add: snd_def)
   128 
   128 
   129 lemma fst_type [TC]: "p \<in> Sigma(A,B) \<Longrightarrow> fst(p) \<in> A"
   129 lemma fst_type [TC]: "p \<in> Sigma(A,B) \<Longrightarrow> fst(p) \<in> A"
   130 by auto
   130 by auto
   131 
   131 
   137 
   137 
   138 
   138 
   139 subsection\<open>The Eliminator, \<^term>\<open>split\<close>\<close>
   139 subsection\<open>The Eliminator, \<^term>\<open>split\<close>\<close>
   140 
   140 
   141 (*A META-equality, so that it applies to higher types as well...*)
   141 (*A META-equality, so that it applies to higher types as well...*)
   142 lemma split [simp]: "split(%x y. c(x,y), <a,b>) \<equiv> c(a,b)"
   142 lemma split [simp]: "split(\<lambda>x y. c(x,y), \<langle>a,b\<rangle>) \<equiv> c(a,b)"
   143 by (simp add: split_def)
   143 by (simp add: split_def)
   144 
   144 
   145 lemma split_type [TC]:
   145 lemma split_type [TC]:
   146     "\<lbrakk>p \<in> Sigma(A,B);
   146     "\<lbrakk>p \<in> Sigma(A,B);
   147          \<And>x y.\<lbrakk>x \<in> A; y \<in> B(x)\<rbrakk> \<Longrightarrow> c(x,y):C(<x,y>)
   147          \<And>x y.\<lbrakk>x \<in> A; y \<in> B(x)\<rbrakk> \<Longrightarrow> c(x,y):C(\<langle>x,y\<rangle>)
   148 \<rbrakk> \<Longrightarrow> split(%x y. c(x,y), p) \<in> C(p)"
   148 \<rbrakk> \<Longrightarrow> split(\<lambda>x y. c(x,y), p) \<in> C(p)"
   149 by (erule SigmaE, auto)
   149 by (erule SigmaE, auto)
   150 
   150 
   151 lemma expand_split:
   151 lemma expand_split:
   152   "u \<in> A*B \<Longrightarrow>
   152   "u \<in> A*B \<Longrightarrow>
   153         R(split(c,u)) \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>B. u = <x,y> \<longrightarrow> R(c(x,y)))"
   153         R(split(c,u)) \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>B. u = \<langle>x,y\<rangle> \<longrightarrow> R(c(x,y)))"
   154 by (auto simp add: split_def)
   154 by (auto simp add: split_def)
   155 
   155 
   156 
   156 
   157 subsection\<open>A version of \<^term>\<open>split\<close> for Formulae: Result Type \<^typ>\<open>o\<close>\<close>
   157 subsection\<open>A version of \<^term>\<open>split\<close> for Formulae: Result Type \<^typ>\<open>o\<close>\<close>
   158 
   158 
   159 lemma splitI: "R(a,b) \<Longrightarrow> split(R, <a,b>)"
   159 lemma splitI: "R(a,b) \<Longrightarrow> split(R, \<langle>a,b\<rangle>)"
   160 by (simp add: split_def)
   160 by (simp add: split_def)
   161 
   161 
   162 lemma splitE:
   162 lemma splitE:
   163     "\<lbrakk>split(R,z);  z \<in> Sigma(A,B);
   163     "\<lbrakk>split(R,z);  z \<in> Sigma(A,B);
   164         \<And>x y. \<lbrakk>z = <x,y>;  R(x,y)\<rbrakk> \<Longrightarrow> P
   164         \<And>x y. \<lbrakk>z = \<langle>x,y\<rangle>;  R(x,y)\<rbrakk> \<Longrightarrow> P
   165 \<rbrakk> \<Longrightarrow> P"
   165 \<rbrakk> \<Longrightarrow> P"
   166 by (auto simp add: split_def)
   166 by (auto simp add: split_def)
   167 
   167 
   168 lemma splitD: "split(R,<a,b>) \<Longrightarrow> R(a,b)"
   168 lemma splitD: "split(R,\<langle>a,b\<rangle>) \<Longrightarrow> R(a,b)"
   169 by (simp add: split_def)
   169 by (simp add: split_def)
   170 
   170 
   171 text \<open>
   171 text \<open>
   172   \bigskip Complex rules for Sigma.
   172   \bigskip Complex rules for Sigma.
   173 \<close>
   173 \<close>
   174 
   174 
   175 lemma split_paired_Bex_Sigma [simp]:
   175 lemma split_paired_Bex_Sigma [simp]:
   176      "(\<exists>z \<in> Sigma(A,B). P(z)) \<longleftrightarrow> (\<exists>x \<in> A. \<exists>y \<in> B(x). P(<x,y>))"
   176      "(\<exists>z \<in> Sigma(A,B). P(z)) \<longleftrightarrow> (\<exists>x \<in> A. \<exists>y \<in> B(x). P(\<langle>x,y\<rangle>))"
   177 by blast
   177 by blast
   178 
   178 
   179 lemma split_paired_Ball_Sigma [simp]:
   179 lemma split_paired_Ball_Sigma [simp]:
   180      "(\<forall>z \<in> Sigma(A,B). P(z)) \<longleftrightarrow> (\<forall>x \<in> A. \<forall>y \<in> B(x). P(<x,y>))"
   180      "(\<forall>z \<in> Sigma(A,B). P(z)) \<longleftrightarrow> (\<forall>x \<in> A. \<forall>y \<in> B(x). P(\<langle>x,y\<rangle>))"
   181 by blast
   181 by blast
   182 
   182 
   183 end
   183 end
   184 
   184 
   185 
   185