src/ZF/pair.thy
author wenzelm
Thu Apr 18 17:07:01 2013 +0200 (2013-04-18)
changeset 51717 9e7d1c139569
parent 48891 c0eafbd55de3
child 54998 8601434fa334
permissions -rw-r--r--
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm@41777
     1
(*  Title:      ZF/pair.thy
paulson@13240
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@13240
     3
    Copyright   1992  University of Cambridge
paulson@13240
     4
*)
paulson@13240
     5
paulson@13357
     6
header{*Ordered Pairs*}
paulson@13357
     7
haftmann@16417
     8
theory pair imports upair
wenzelm@42455
     9
begin
wenzelm@42455
    10
wenzelm@48891
    11
ML_file "simpdata.ML"
wenzelm@48891
    12
wenzelm@42795
    13
setup {*
wenzelm@51717
    14
  map_theory_simpset
wenzelm@45625
    15
    (Simplifier.set_mksimps (K (map mk_eq o ZF_atomize o gen_all))
wenzelm@45625
    16
      #> Simplifier.add_cong @{thm if_weak_cong})
wenzelm@42794
    17
*}
wenzelm@42794
    18
wenzelm@51717
    19
ML {* val ZF_ss = simpset_of @{context} *}
wenzelm@42794
    20
paulson@46820
    21
simproc_setup defined_Bex ("\<exists>x\<in>A. P(x) & Q(x)") = {*
wenzelm@42455
    22
  let
wenzelm@42455
    23
    val unfold_bex_tac = unfold_tac @{thms Bex_def};
wenzelm@51717
    24
    fun prove_bex_tac ctxt = unfold_bex_tac ctxt THEN Quantifier1.prove_one_point_ex_tac;
wenzelm@51717
    25
  in fn _ => fn ctxt => Quantifier1.rearrange_bex (prove_bex_tac ctxt) ctxt end
wenzelm@42455
    26
*}
wenzelm@42455
    27
paulson@46820
    28
simproc_setup defined_Ball ("\<forall>x\<in>A. P(x) \<longrightarrow> Q(x)") = {*
wenzelm@42455
    29
  let
wenzelm@42455
    30
    val unfold_ball_tac = unfold_tac @{thms Ball_def};
wenzelm@51717
    31
    fun prove_ball_tac ctxt = unfold_ball_tac ctxt THEN Quantifier1.prove_one_point_all_tac;
wenzelm@51717
    32
  in fn _ => fn ctxt => Quantifier1.rearrange_ball (prove_ball_tac ctxt) ctxt end
wenzelm@42455
    33
*}
wenzelm@42455
    34
paulson@13240
    35
paulson@13240
    36
(** Lemmas for showing that <a,b> uniquely determines a and b **)
paulson@13240
    37
paulson@46821
    38
lemma singleton_eq_iff [iff]: "{a} = {b} \<longleftrightarrow> a=b"
paulson@13240
    39
by (rule extension [THEN iff_trans], blast)
paulson@13240
    40
paulson@46821
    41
lemma doubleton_eq_iff: "{a,b} = {c,d} \<longleftrightarrow> (a=c & b=d) | (a=d & b=c)"
paulson@13240
    42
by (rule extension [THEN iff_trans], blast)
paulson@13240
    43
paulson@46821
    44
lemma Pair_iff [simp]: "<a,b> = <c,d> \<longleftrightarrow> a=c & b=d"
paulson@13240
    45
by (simp add: Pair_def doubleton_eq_iff, blast)
paulson@13240
    46
wenzelm@45602
    47
lemmas Pair_inject = Pair_iff [THEN iffD1, THEN conjE, elim!]
paulson@13240
    48
wenzelm@45602
    49
lemmas Pair_inject1 = Pair_iff [THEN iffD1, THEN conjunct1]
wenzelm@45602
    50
lemmas Pair_inject2 = Pair_iff [THEN iffD1, THEN conjunct2]
paulson@13240
    51
paulson@46820
    52
lemma Pair_not_0: "<a,b> \<noteq> 0"
paulson@13240
    53
apply (unfold Pair_def)
paulson@13240
    54
apply (blast elim: equalityE)
paulson@13240
    55
done
paulson@13240
    56
wenzelm@45602
    57
lemmas Pair_neq_0 = Pair_not_0 [THEN notE, elim!]
paulson@13240
    58
paulson@13240
    59
declare sym [THEN Pair_neq_0, elim!]
paulson@13240
    60
paulson@13240
    61
lemma Pair_neq_fst: "<a,b>=a ==> P"
paulson@46841
    62
proof (unfold Pair_def)
paulson@46841
    63
  assume eq: "{{a, a}, {a, b}} = a"
paulson@46841
    64
  have  "{a, a} \<in> {{a, a}, {a, b}}" by (rule consI1)
paulson@46841
    65
  hence "{a, a} \<in> a" by (simp add: eq)
paulson@46841
    66
  moreover have "a \<in> {a, a}" by (rule consI1)
paulson@46953
    67
  ultimately show "P" by (rule mem_asym)
paulson@46841
    68
qed
paulson@13240
    69
paulson@13240
    70
lemma Pair_neq_snd: "<a,b>=b ==> P"
paulson@46841
    71
proof (unfold Pair_def)
paulson@46841
    72
  assume eq: "{{a, a}, {a, b}} = b"
paulson@46841
    73
  have  "{a, b} \<in> {{a, a}, {a, b}}" by blast
paulson@46841
    74
  hence "{a, b} \<in> b" by (simp add: eq)
paulson@46841
    75
  moreover have "b \<in> {a, b}" by blast
paulson@46953
    76
  ultimately show "P" by (rule mem_asym)
paulson@46841
    77
qed
paulson@13240
    78
paulson@13240
    79
paulson@13357
    80
subsection{*Sigma: Disjoint Union of a Family of Sets*}
paulson@13357
    81
paulson@13357
    82
text{*Generalizes Cartesian product*}
paulson@13240
    83
paulson@46953
    84
lemma Sigma_iff [simp]: "<a,b>: Sigma(A,B) \<longleftrightarrow> a \<in> A & b \<in> B(a)"
paulson@13240
    85
by (simp add: Sigma_def)
paulson@13240
    86
paulson@46953
    87
lemma SigmaI [TC,intro!]: "[| a \<in> A;  b \<in> B(a) |] ==> <a,b> \<in> Sigma(A,B)"
paulson@13240
    88
by simp
paulson@13240
    89
wenzelm@45602
    90
lemmas SigmaD1 = Sigma_iff [THEN iffD1, THEN conjunct1]
wenzelm@45602
    91
lemmas SigmaD2 = Sigma_iff [THEN iffD1, THEN conjunct2]
paulson@13240
    92
paulson@13240
    93
(*The general elimination rule*)
paulson@13240
    94
lemma SigmaE [elim!]:
paulson@46953
    95
    "[| c \<in> Sigma(A,B);
paulson@46953
    96
        !!x y.[| x \<in> A;  y \<in> B(x);  c=<x,y> |] ==> P
paulson@13240
    97
     |] ==> P"
paulson@46953
    98
by (unfold Sigma_def, blast)
paulson@13240
    99
paulson@13240
   100
lemma SigmaE2 [elim!]:
paulson@46953
   101
    "[| <a,b> \<in> Sigma(A,B);
paulson@46953
   102
        [| a \<in> A;  b \<in> B(a) |] ==> P
paulson@13240
   103
     |] ==> P"
paulson@46953
   104
by (unfold Sigma_def, blast)
paulson@13240
   105
paulson@13240
   106
lemma Sigma_cong:
paulson@46953
   107
    "[| A=A';  !!x. x \<in> A' ==> B(x)=B'(x) |] ==>
paulson@13240
   108
     Sigma(A,B) = Sigma(A',B')"
paulson@13240
   109
by (simp add: Sigma_def)
paulson@13240
   110
paulson@13240
   111
(*Sigma_cong, Pi_cong NOT given to Addcongs: they cause
paulson@13240
   112
  flex-flex pairs and the "Check your prover" error.  Most
paulson@13240
   113
  Sigmas and Pis are abbreviated as * or -> *)
paulson@13240
   114
paulson@13240
   115
lemma Sigma_empty1 [simp]: "Sigma(0,B) = 0"
paulson@13240
   116
by blast
paulson@13240
   117
paulson@13240
   118
lemma Sigma_empty2 [simp]: "A*0 = 0"
paulson@13240
   119
by blast
paulson@13240
   120
paulson@46821
   121
lemma Sigma_empty_iff: "A*B=0 \<longleftrightarrow> A=0 | B=0"
paulson@13240
   122
by blast
paulson@13240
   123
paulson@13240
   124
paulson@13357
   125
subsection{*Projections @{term fst} and @{term snd}*}
paulson@13240
   126
paulson@13240
   127
lemma fst_conv [simp]: "fst(<a,b>) = a"
paulson@13544
   128
by (simp add: fst_def)
paulson@13240
   129
paulson@13240
   130
lemma snd_conv [simp]: "snd(<a,b>) = b"
paulson@13544
   131
by (simp add: snd_def)
paulson@13240
   132
paulson@46953
   133
lemma fst_type [TC]: "p \<in> Sigma(A,B) ==> fst(p) \<in> A"
paulson@13240
   134
by auto
paulson@13240
   135
paulson@46953
   136
lemma snd_type [TC]: "p \<in> Sigma(A,B) ==> snd(p) \<in> B(fst(p))"
paulson@13240
   137
by auto
paulson@13240
   138
paulson@46953
   139
lemma Pair_fst_snd_eq: "a \<in> Sigma(A,B) ==> <fst(a),snd(a)> = a"
paulson@13240
   140
by auto
paulson@13240
   141
paulson@13240
   142
paulson@13357
   143
subsection{*The Eliminator, @{term split}*}
paulson@13240
   144
paulson@13240
   145
(*A META-equality, so that it applies to higher types as well...*)
paulson@13240
   146
lemma split [simp]: "split(%x y. c(x,y), <a,b>) == c(a,b)"
paulson@13240
   147
by (simp add: split_def)
paulson@13240
   148
paulson@13240
   149
lemma split_type [TC]:
paulson@46953
   150
    "[|  p \<in> Sigma(A,B);
paulson@46953
   151
         !!x y.[| x \<in> A; y \<in> B(x) |] ==> c(x,y):C(<x,y>)
paulson@46820
   152
     |] ==> split(%x y. c(x,y), p) \<in> C(p)"
paulson@46953
   153
by (erule SigmaE, auto)
paulson@13240
   154
paulson@46953
   155
lemma expand_split:
paulson@46953
   156
  "u \<in> A*B ==>
paulson@46821
   157
        R(split(c,u)) \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>B. u = <x,y> \<longrightarrow> R(c(x,y)))"
paulson@46841
   158
by (auto simp add: split_def)
paulson@13240
   159
paulson@13240
   160
paulson@13357
   161
subsection{*A version of @{term split} for Formulae: Result Type @{typ o}*}
paulson@13240
   162
paulson@13240
   163
lemma splitI: "R(a,b) ==> split(R, <a,b>)"
paulson@13240
   164
by (simp add: split_def)
paulson@13240
   165
paulson@13240
   166
lemma splitE:
paulson@46953
   167
    "[| split(R,z);  z \<in> Sigma(A,B);
paulson@46953
   168
        !!x y. [| z = <x,y>;  R(x,y) |] ==> P
paulson@13240
   169
     |] ==> P"
paulson@46841
   170
by (auto simp add: split_def)
paulson@13240
   171
paulson@13240
   172
lemma splitD: "split(R,<a,b>) ==> R(a,b)"
paulson@13240
   173
by (simp add: split_def)
paulson@13240
   174
paulson@14864
   175
text {*
paulson@14864
   176
  \bigskip Complex rules for Sigma.
paulson@14864
   177
*}
paulson@14864
   178
paulson@14864
   179
lemma split_paired_Bex_Sigma [simp]:
paulson@46821
   180
     "(\<exists>z \<in> Sigma(A,B). P(z)) \<longleftrightarrow> (\<exists>x \<in> A. \<exists>y \<in> B(x). P(<x,y>))"
paulson@14864
   181
by blast
paulson@14864
   182
paulson@14864
   183
lemma split_paired_Ball_Sigma [simp]:
paulson@46821
   184
     "(\<forall>z \<in> Sigma(A,B). P(z)) \<longleftrightarrow> (\<forall>x \<in> A. \<forall>y \<in> B(x). P(<x,y>))"
paulson@14864
   185
by blast
paulson@14864
   186
paulson@9570
   187
end
clasohm@124
   188
paulson@2469
   189