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