src/ZF/pair.thy
author wenzelm
Fri May 13 23:24:06 2011 +0200 (2011-05-13)
changeset 42794 07155da3b2f4
parent 42459 38b9f023cc34
child 42795 66fcc9882784
permissions -rw-r--r--
make ZF_cs snapshot after final setup;
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
uses "simpdata.ML"
wenzelm@42455
    10
begin
wenzelm@42455
    11
wenzelm@42794
    12
declaration {*
wenzelm@42794
    13
  fn _ => Simplifier.map_ss (fn ss =>
wenzelm@42794
    14
    ss setmksimps (K (map mk_eq o ZF_atomize o gen_all))
wenzelm@42794
    15
    addcongs [@{thm if_weak_cong}])
wenzelm@42794
    16
*}
wenzelm@42794
    17
wenzelm@42794
    18
ML {* val ZF_ss = @{simpset} *}
wenzelm@42794
    19
wenzelm@42455
    20
simproc_setup defined_Bex ("EX x:A. P(x) & Q(x)") = {*
wenzelm@42455
    21
  let
wenzelm@42455
    22
    val unfold_bex_tac = unfold_tac @{thms Bex_def};
wenzelm@42455
    23
    fun prove_bex_tac ss = unfold_bex_tac ss THEN Quantifier1.prove_one_point_ex_tac;
wenzelm@42459
    24
  in fn _ => fn ss => Quantifier1.rearrange_bex (prove_bex_tac ss) ss end
wenzelm@42455
    25
*}
wenzelm@42455
    26
wenzelm@42455
    27
simproc_setup defined_Ball ("ALL x:A. P(x) --> Q(x)") = {*
wenzelm@42455
    28
  let
wenzelm@42455
    29
    val unfold_ball_tac = unfold_tac @{thms Ball_def};
wenzelm@42455
    30
    fun prove_ball_tac ss = unfold_ball_tac ss THEN Quantifier1.prove_one_point_all_tac;
wenzelm@42459
    31
  in fn _ => fn ss => Quantifier1.rearrange_ball (prove_ball_tac ss) ss end
wenzelm@42455
    32
*}
wenzelm@42455
    33
paulson@13240
    34
paulson@13240
    35
(** Lemmas for showing that <a,b> uniquely determines a and b **)
paulson@13240
    36
paulson@13240
    37
lemma singleton_eq_iff [iff]: "{a} = {b} <-> a=b"
paulson@13240
    38
by (rule extension [THEN iff_trans], blast)
paulson@13240
    39
paulson@13240
    40
lemma doubleton_eq_iff: "{a,b} = {c,d} <-> (a=c & b=d) | (a=d & b=c)"
paulson@13240
    41
by (rule extension [THEN iff_trans], blast)
paulson@13240
    42
paulson@13240
    43
lemma Pair_iff [simp]: "<a,b> = <c,d> <-> a=c & b=d"
paulson@13240
    44
by (simp add: Pair_def doubleton_eq_iff, blast)
paulson@13240
    45
paulson@13240
    46
lemmas Pair_inject = Pair_iff [THEN iffD1, THEN conjE, standard, elim!]
paulson@13240
    47
paulson@13240
    48
lemmas Pair_inject1 = Pair_iff [THEN iffD1, THEN conjunct1, standard]
paulson@13240
    49
lemmas Pair_inject2 = Pair_iff [THEN iffD1, THEN conjunct2, standard]
paulson@13240
    50
paulson@13240
    51
lemma Pair_not_0: "<a,b> ~= 0"
paulson@13240
    52
apply (unfold Pair_def)
paulson@13240
    53
apply (blast elim: equalityE)
paulson@13240
    54
done
paulson@13240
    55
paulson@13240
    56
lemmas Pair_neq_0 = Pair_not_0 [THEN notE, standard, elim!]
paulson@13240
    57
paulson@13240
    58
declare sym [THEN Pair_neq_0, elim!]
paulson@13240
    59
paulson@13240
    60
lemma Pair_neq_fst: "<a,b>=a ==> P"
paulson@13240
    61
apply (unfold Pair_def)
paulson@13240
    62
apply (rule consI1 [THEN mem_asym, THEN FalseE])
paulson@13240
    63
apply (erule subst)
paulson@13240
    64
apply (rule consI1)
paulson@13240
    65
done
paulson@13240
    66
paulson@13240
    67
lemma Pair_neq_snd: "<a,b>=b ==> P"
paulson@13240
    68
apply (unfold Pair_def)
paulson@13240
    69
apply (rule consI1 [THEN consI2, THEN mem_asym, THEN FalseE])
paulson@13240
    70
apply (erule subst)
paulson@13240
    71
apply (rule consI1 [THEN consI2])
paulson@13240
    72
done
paulson@13240
    73
paulson@13240
    74
paulson@13357
    75
subsection{*Sigma: Disjoint Union of a Family of Sets*}
paulson@13357
    76
paulson@13357
    77
text{*Generalizes Cartesian product*}
paulson@13240
    78
paulson@13240
    79
lemma Sigma_iff [simp]: "<a,b>: Sigma(A,B) <-> a:A & b:B(a)"
paulson@13240
    80
by (simp add: Sigma_def)
paulson@13240
    81
paulson@13240
    82
lemma SigmaI [TC,intro!]: "[| a:A;  b:B(a) |] ==> <a,b> : Sigma(A,B)"
paulson@13240
    83
by simp
paulson@13240
    84
paulson@13240
    85
lemmas SigmaD1 = Sigma_iff [THEN iffD1, THEN conjunct1, standard]
paulson@13240
    86
lemmas SigmaD2 = Sigma_iff [THEN iffD1, THEN conjunct2, standard]
paulson@13240
    87
paulson@13240
    88
(*The general elimination rule*)
paulson@13240
    89
lemma SigmaE [elim!]:
paulson@13240
    90
    "[| c: Sigma(A,B);   
paulson@13240
    91
        !!x y.[| x:A;  y:B(x);  c=<x,y> |] ==> P  
paulson@13240
    92
     |] ==> P"
paulson@13357
    93
by (unfold Sigma_def, blast) 
paulson@13240
    94
paulson@13240
    95
lemma SigmaE2 [elim!]:
paulson@13240
    96
    "[| <a,b> : Sigma(A,B);     
paulson@13240
    97
        [| a:A;  b:B(a) |] ==> P    
paulson@13240
    98
     |] ==> P"
paulson@13357
    99
by (unfold Sigma_def, blast) 
paulson@13240
   100
paulson@13240
   101
lemma Sigma_cong:
paulson@13240
   102
    "[| A=A';  !!x. x:A' ==> B(x)=B'(x) |] ==>  
paulson@13240
   103
     Sigma(A,B) = Sigma(A',B')"
paulson@13240
   104
by (simp add: Sigma_def)
paulson@13240
   105
paulson@13240
   106
(*Sigma_cong, Pi_cong NOT given to Addcongs: they cause
paulson@13240
   107
  flex-flex pairs and the "Check your prover" error.  Most
paulson@13240
   108
  Sigmas and Pis are abbreviated as * or -> *)
paulson@13240
   109
paulson@13240
   110
lemma Sigma_empty1 [simp]: "Sigma(0,B) = 0"
paulson@13240
   111
by blast
paulson@13240
   112
paulson@13240
   113
lemma Sigma_empty2 [simp]: "A*0 = 0"
paulson@13240
   114
by blast
paulson@13240
   115
paulson@13240
   116
lemma Sigma_empty_iff: "A*B=0 <-> A=0 | B=0"
paulson@13240
   117
by blast
paulson@13240
   118
paulson@13240
   119
paulson@13357
   120
subsection{*Projections @{term fst} and @{term snd}*}
paulson@13240
   121
paulson@13240
   122
lemma fst_conv [simp]: "fst(<a,b>) = a"
paulson@13544
   123
by (simp add: fst_def)
paulson@13240
   124
paulson@13240
   125
lemma snd_conv [simp]: "snd(<a,b>) = b"
paulson@13544
   126
by (simp add: snd_def)
paulson@13240
   127
paulson@13240
   128
lemma fst_type [TC]: "p:Sigma(A,B) ==> fst(p) : A"
paulson@13240
   129
by auto
paulson@13240
   130
paulson@13240
   131
lemma snd_type [TC]: "p:Sigma(A,B) ==> snd(p) : B(fst(p))"
paulson@13240
   132
by auto
paulson@13240
   133
paulson@13240
   134
lemma Pair_fst_snd_eq: "a: Sigma(A,B) ==> <fst(a),snd(a)> = a"
paulson@13240
   135
by auto
paulson@13240
   136
paulson@13240
   137
paulson@13357
   138
subsection{*The Eliminator, @{term split}*}
paulson@13240
   139
paulson@13240
   140
(*A META-equality, so that it applies to higher types as well...*)
paulson@13240
   141
lemma split [simp]: "split(%x y. c(x,y), <a,b>) == c(a,b)"
paulson@13240
   142
by (simp add: split_def)
paulson@13240
   143
paulson@13240
   144
lemma split_type [TC]:
paulson@13240
   145
    "[|  p:Sigma(A,B);    
paulson@13240
   146
         !!x y.[| x:A; y:B(x) |] ==> c(x,y):C(<x,y>)  
paulson@13240
   147
     |] ==> split(%x y. c(x,y), p) : C(p)"
paulson@13240
   148
apply (erule SigmaE, auto) 
paulson@13240
   149
done
paulson@13240
   150
paulson@13240
   151
lemma expand_split: 
paulson@13240
   152
  "u: A*B ==>    
paulson@13240
   153
        R(split(c,u)) <-> (ALL x:A. ALL y:B. u = <x,y> --> R(c(x,y)))"
wenzelm@17001
   154
apply (simp add: split_def)
wenzelm@17001
   155
apply auto
paulson@13240
   156
done
paulson@13240
   157
paulson@13240
   158
paulson@13357
   159
subsection{*A version of @{term split} for Formulae: Result Type @{typ o}*}
paulson@13240
   160
paulson@13240
   161
lemma splitI: "R(a,b) ==> split(R, <a,b>)"
paulson@13240
   162
by (simp add: split_def)
paulson@13240
   163
paulson@13240
   164
lemma splitE:
paulson@13240
   165
    "[| split(R,z);  z:Sigma(A,B);                       
paulson@13240
   166
        !!x y. [| z = <x,y>;  R(x,y) |] ==> P            
paulson@13240
   167
     |] ==> P"
paulson@13240
   168
apply (simp add: split_def)
paulson@13240
   169
apply (erule SigmaE, force) 
paulson@13240
   170
done
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@14864
   180
     "(\<exists>z \<in> Sigma(A,B). P(z)) <-> (\<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@14864
   184
     "(\<forall>z \<in> Sigma(A,B). P(z)) <-> (\<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