src/ZF/QPair.thy
author wenzelm
Sun Oct 07 21:19:31 2007 +0200 (2007-10-07)
changeset 24893 b8ef7afe3a6b
parent 22808 a7daa74e2980
child 35762 af3ff2ba4c54
permissions -rw-r--r--
modernized specifications;
removed legacy ML bindings;
clasohm@1478
     1
(*  Title:      ZF/qpair.thy
clasohm@0
     2
    ID:         $Id$
clasohm@1478
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1993  University of Cambridge
clasohm@0
     5
paulson@13285
     6
Many proofs are borrowed from pair.thy and sum.thy
paulson@13285
     7
paulson@13285
     8
Do we EVER have rank(a) < rank(<a;b>) ?  Perhaps if the latter rank
paulson@13285
     9
    is not a limit ordinal? 
clasohm@0
    10
*)
clasohm@0
    11
paulson@13356
    12
header{*Quine-Inspired Ordered Pairs and Disjoint Sums*}
paulson@13356
    13
haftmann@16417
    14
theory QPair imports Sum func begin
paulson@13285
    15
paulson@13356
    16
text{*For non-well-founded data
paulson@13356
    17
structures in ZF.  Does not precisely follow Quine's construction.  Thanks
paulson@13356
    18
to Thomas Forster for suggesting this approach!
paulson@13356
    19
paulson@13356
    20
W. V. Quine, On Ordered Pairs and Relations, in Selected Logic Papers,
paulson@13356
    21
1966.
paulson@13356
    22
*}
paulson@13356
    23
wenzelm@24893
    24
definition
wenzelm@24893
    25
  QPair     :: "[i, i] => i"                      ("<(_;/ _)>")  where
paulson@13285
    26
    "<a;b> == a+b"
wenzelm@3923
    27
wenzelm@24893
    28
definition
wenzelm@24893
    29
  qfst :: "i => i"  where
paulson@13285
    30
    "qfst(p) == THE a. EX b. p=<a;b>"
paulson@13285
    31
wenzelm@24893
    32
definition
wenzelm@24893
    33
  qsnd :: "i => i"  where
paulson@13285
    34
    "qsnd(p) == THE b. EX a. p=<a;b>"
paulson@13285
    35
wenzelm@24893
    36
definition
wenzelm@24893
    37
  qsplit    :: "[[i, i] => 'a, i] => 'a::{}"  (*for pattern-matching*)  where
paulson@13285
    38
    "qsplit(c,p) == c(qfst(p), qsnd(p))"
clasohm@0
    39
wenzelm@24893
    40
definition
wenzelm@24893
    41
  qconverse :: "i => i"  where
paulson@13285
    42
    "qconverse(r) == {z. w:r, EX x y. w=<x;y> & z=<y;x>}"
paulson@13285
    43
wenzelm@24893
    44
definition
wenzelm@24893
    45
  QSigma    :: "[i, i => i] => i"  where
paulson@13615
    46
    "QSigma(A,B)  ==  \<Union>x\<in>A. \<Union>y\<in>B(x). {<x;y>}"
clasohm@0
    47
lcp@929
    48
syntax
wenzelm@22808
    49
  "_QSUM"   :: "[idt, i, i] => i"               ("(3QSUM _:_./ _)" 10)
clasohm@0
    50
translations
wenzelm@24893
    51
  "QSUM x:A. B"  => "CONST QSigma(A, %x. B)"
wenzelm@22808
    52
wenzelm@22808
    53
abbreviation
wenzelm@22808
    54
  qprod  (infixr "<*>" 80) where
wenzelm@22808
    55
  "A <*> B == QSigma(A, %_. B)"
clasohm@0
    56
wenzelm@24893
    57
definition
wenzelm@24893
    58
  qsum    :: "[i,i]=>i"                         (infixr "<+>" 65)  where
paulson@13285
    59
    "A <+> B      == ({0} <*> A) Un ({1} <*> B)"
wenzelm@3923
    60
wenzelm@24893
    61
definition
wenzelm@24893
    62
  QInl :: "i=>i"  where
paulson@13285
    63
    "QInl(a)      == <0;a>"
paulson@13285
    64
wenzelm@24893
    65
definition
wenzelm@24893
    66
  QInr :: "i=>i"  where
paulson@13285
    67
    "QInr(b)      == <1;b>"
paulson@13285
    68
wenzelm@24893
    69
definition
wenzelm@24893
    70
  qcase     :: "[i=>i, i=>i, i]=>i"  where
paulson@13285
    71
    "qcase(c,d)   == qsplit(%y z. cond(y, d(z), c(z)))"
paulson@13285
    72
paulson@13285
    73
paulson@13356
    74
subsection{*Quine ordered pairing*}
paulson@13285
    75
paulson@13285
    76
(** Lemmas for showing that <a;b> uniquely determines a and b **)
paulson@13285
    77
paulson@13285
    78
lemma QPair_empty [simp]: "<0;0> = 0"
paulson@13285
    79
by (simp add: QPair_def)
paulson@13285
    80
paulson@13285
    81
lemma QPair_iff [simp]: "<a;b> = <c;d> <-> a=c & b=d"
paulson@13285
    82
apply (simp add: QPair_def)
paulson@13285
    83
apply (rule sum_equal_iff)
paulson@13285
    84
done
paulson@13285
    85
paulson@13285
    86
lemmas QPair_inject = QPair_iff [THEN iffD1, THEN conjE, standard, elim!]
paulson@13285
    87
paulson@13285
    88
lemma QPair_inject1: "<a;b> = <c;d> ==> a=c"
paulson@13285
    89
by blast
paulson@13285
    90
paulson@13285
    91
lemma QPair_inject2: "<a;b> = <c;d> ==> b=d"
paulson@13285
    92
by blast
paulson@13285
    93
paulson@13285
    94
paulson@13356
    95
subsubsection{*QSigma: Disjoint union of a family of sets
paulson@13356
    96
     Generalizes Cartesian product*}
paulson@13285
    97
paulson@13285
    98
lemma QSigmaI [intro!]: "[| a:A;  b:B(a) |] ==> <a;b> : QSigma(A,B)"
paulson@13285
    99
by (simp add: QSigma_def)
paulson@13285
   100
paulson@13285
   101
paulson@13285
   102
(** Elimination rules for <a;b>:A*B -- introducing no eigenvariables **)
paulson@13285
   103
paulson@13285
   104
lemma QSigmaE [elim!]:
paulson@13285
   105
    "[| c: QSigma(A,B);   
paulson@13285
   106
        !!x y.[| x:A;  y:B(x);  c=<x;y> |] ==> P  
paulson@13285
   107
     |] ==> P"
paulson@13356
   108
by (simp add: QSigma_def, blast) 
paulson@13285
   109
paulson@13285
   110
lemma QSigmaE2 [elim!]:
paulson@13285
   111
    "[| <a;b>: QSigma(A,B); [| a:A;  b:B(a) |] ==> P |] ==> P"
paulson@13285
   112
by (simp add: QSigma_def) 
paulson@13285
   113
paulson@13285
   114
lemma QSigmaD1: "<a;b> : QSigma(A,B) ==> a : A"
paulson@13285
   115
by blast
paulson@13285
   116
paulson@13285
   117
lemma QSigmaD2: "<a;b> : QSigma(A,B) ==> b : B(a)"
paulson@13285
   118
by blast
paulson@13285
   119
paulson@13285
   120
lemma QSigma_cong:
paulson@13285
   121
    "[| A=A';  !!x. x:A' ==> B(x)=B'(x) |] ==>  
paulson@13285
   122
     QSigma(A,B) = QSigma(A',B')"
paulson@13285
   123
by (simp add: QSigma_def) 
paulson@13285
   124
paulson@13285
   125
lemma QSigma_empty1 [simp]: "QSigma(0,B) = 0"
paulson@13285
   126
by blast
paulson@13285
   127
paulson@13285
   128
lemma QSigma_empty2 [simp]: "A <*> 0 = 0"
paulson@13285
   129
by blast
paulson@13285
   130
paulson@13285
   131
paulson@13356
   132
subsubsection{*Projections: qfst, qsnd*}
paulson@13285
   133
paulson@13285
   134
lemma qfst_conv [simp]: "qfst(<a;b>) = a"
paulson@13544
   135
by (simp add: qfst_def)
paulson@13285
   136
paulson@13285
   137
lemma qsnd_conv [simp]: "qsnd(<a;b>) = b"
paulson@13544
   138
by (simp add: qsnd_def)
paulson@13285
   139
paulson@13285
   140
lemma qfst_type [TC]: "p:QSigma(A,B) ==> qfst(p) : A"
paulson@13285
   141
by auto
paulson@13285
   142
paulson@13285
   143
lemma qsnd_type [TC]: "p:QSigma(A,B) ==> qsnd(p) : B(qfst(p))"
paulson@13285
   144
by auto
paulson@13285
   145
paulson@13285
   146
lemma QPair_qfst_qsnd_eq: "a: QSigma(A,B) ==> <qfst(a); qsnd(a)> = a"
paulson@13285
   147
by auto
paulson@13285
   148
paulson@13285
   149
paulson@13356
   150
subsubsection{*Eliminator: qsplit*}
paulson@13285
   151
paulson@13285
   152
(*A META-equality, so that it applies to higher types as well...*)
paulson@13285
   153
lemma qsplit [simp]: "qsplit(%x y. c(x,y), <a;b>) == c(a,b)"
paulson@13285
   154
by (simp add: qsplit_def)
paulson@13285
   155
paulson@13285
   156
paulson@13285
   157
lemma qsplit_type [elim!]:
paulson@13285
   158
    "[|  p:QSigma(A,B);    
paulson@13285
   159
         !!x y.[| x:A; y:B(x) |] ==> c(x,y):C(<x;y>)  
paulson@13285
   160
     |] ==> qsplit(%x y. c(x,y), p) : C(p)"
paulson@13285
   161
by auto 
paulson@13285
   162
paulson@13285
   163
lemma expand_qsplit: 
paulson@13285
   164
 "u: A<*>B ==> R(qsplit(c,u)) <-> (ALL x:A. ALL y:B. u = <x;y> --> R(c(x,y)))"
paulson@13285
   165
apply (simp add: qsplit_def, auto)
paulson@13285
   166
done
paulson@13285
   167
paulson@13285
   168
paulson@13356
   169
subsubsection{*qsplit for predicates: result type o*}
paulson@13285
   170
paulson@13285
   171
lemma qsplitI: "R(a,b) ==> qsplit(R, <a;b>)"
paulson@13285
   172
by (simp add: qsplit_def)
paulson@13285
   173
paulson@13285
   174
paulson@13285
   175
lemma qsplitE:
paulson@13285
   176
    "[| qsplit(R,z);  z:QSigma(A,B);                     
paulson@13285
   177
        !!x y. [| z = <x;y>;  R(x,y) |] ==> P            
paulson@13285
   178
    |] ==> P"
paulson@13356
   179
by (simp add: qsplit_def, auto) 
paulson@13285
   180
paulson@13285
   181
lemma qsplitD: "qsplit(R,<a;b>) ==> R(a,b)"
paulson@13285
   182
by (simp add: qsplit_def)
paulson@13285
   183
paulson@13285
   184
paulson@13356
   185
subsubsection{*qconverse*}
paulson@13285
   186
paulson@13285
   187
lemma qconverseI [intro!]: "<a;b>:r ==> <b;a>:qconverse(r)"
paulson@13285
   188
by (simp add: qconverse_def, blast)
paulson@13285
   189
paulson@13285
   190
lemma qconverseD [elim!]: "<a;b> : qconverse(r) ==> <b;a> : r"
paulson@13285
   191
by (simp add: qconverse_def, blast)
paulson@13285
   192
paulson@13285
   193
lemma qconverseE [elim!]:
paulson@13285
   194
    "[| yx : qconverse(r);   
paulson@13285
   195
        !!x y. [| yx=<y;x>;  <x;y>:r |] ==> P  
paulson@13285
   196
     |] ==> P"
paulson@13356
   197
by (simp add: qconverse_def, blast) 
paulson@13285
   198
paulson@13285
   199
lemma qconverse_qconverse: "r<=QSigma(A,B) ==> qconverse(qconverse(r)) = r"
paulson@13285
   200
by blast
paulson@13285
   201
paulson@13285
   202
lemma qconverse_type: "r <= A <*> B ==> qconverse(r) <= B <*> A"
paulson@13285
   203
by blast
paulson@13285
   204
paulson@13285
   205
lemma qconverse_prod: "qconverse(A <*> B) = B <*> A"
paulson@13285
   206
by blast
paulson@13285
   207
paulson@13285
   208
lemma qconverse_empty: "qconverse(0) = 0"
paulson@13285
   209
by blast
paulson@13285
   210
paulson@13285
   211
paulson@13356
   212
subsection{*The Quine-inspired notion of disjoint sum*}
paulson@13285
   213
paulson@13285
   214
lemmas qsum_defs = qsum_def QInl_def QInr_def qcase_def
paulson@13285
   215
paulson@13285
   216
(** Introduction rules for the injections **)
paulson@13285
   217
paulson@13285
   218
lemma QInlI [intro!]: "a : A ==> QInl(a) : A <+> B"
paulson@13285
   219
by (simp add: qsum_defs, blast)
lcp@1097
   220
paulson@13285
   221
lemma QInrI [intro!]: "b : B ==> QInr(b) : A <+> B"
paulson@13285
   222
by (simp add: qsum_defs, blast)
paulson@13285
   223
paulson@13285
   224
(** Elimination rules **)
paulson@13285
   225
paulson@13285
   226
lemma qsumE [elim!]:
paulson@13285
   227
    "[| u: A <+> B;   
paulson@13285
   228
        !!x. [| x:A;  u=QInl(x) |] ==> P;  
paulson@13285
   229
        !!y. [| y:B;  u=QInr(y) |] ==> P  
paulson@13285
   230
     |] ==> P"
paulson@13356
   231
by (simp add: qsum_defs, blast) 
paulson@13285
   232
paulson@13285
   233
paulson@13285
   234
(** Injection and freeness equivalences, for rewriting **)
paulson@13285
   235
paulson@13285
   236
lemma QInl_iff [iff]: "QInl(a)=QInl(b) <-> a=b"
paulson@13285
   237
by (simp add: qsum_defs )
paulson@13285
   238
paulson@13285
   239
lemma QInr_iff [iff]: "QInr(a)=QInr(b) <-> a=b"
paulson@13285
   240
by (simp add: qsum_defs )
paulson@13285
   241
paulson@13823
   242
lemma QInl_QInr_iff [simp]: "QInl(a)=QInr(b) <-> False"
paulson@13285
   243
by (simp add: qsum_defs )
paulson@13285
   244
paulson@13823
   245
lemma QInr_QInl_iff [simp]: "QInr(b)=QInl(a) <-> False"
paulson@13285
   246
by (simp add: qsum_defs )
paulson@13285
   247
paulson@13285
   248
lemma qsum_empty [simp]: "0<+>0 = 0"
paulson@13285
   249
by (simp add: qsum_defs )
paulson@13285
   250
paulson@13285
   251
(*Injection and freeness rules*)
paulson@13285
   252
paulson@13285
   253
lemmas QInl_inject = QInl_iff [THEN iffD1, standard]
paulson@13285
   254
lemmas QInr_inject = QInr_iff [THEN iffD1, standard]
paulson@13823
   255
lemmas QInl_neq_QInr = QInl_QInr_iff [THEN iffD1, THEN FalseE, elim!]
paulson@13823
   256
lemmas QInr_neq_QInl = QInr_QInl_iff [THEN iffD1, THEN FalseE, elim!]
paulson@13285
   257
paulson@13285
   258
lemma QInlD: "QInl(a): A<+>B ==> a: A"
paulson@13285
   259
by blast
paulson@13285
   260
paulson@13285
   261
lemma QInrD: "QInr(b): A<+>B ==> b: B"
paulson@13285
   262
by blast
paulson@13285
   263
paulson@13285
   264
(** <+> is itself injective... who cares?? **)
paulson@13285
   265
paulson@13285
   266
lemma qsum_iff:
paulson@13285
   267
     "u: A <+> B <-> (EX x. x:A & u=QInl(x)) | (EX y. y:B & u=QInr(y))"
paulson@13356
   268
by blast
paulson@13285
   269
paulson@13285
   270
lemma qsum_subset_iff: "A <+> B <= C <+> D <-> A<=C & B<=D"
paulson@13285
   271
by blast
paulson@13285
   272
paulson@13285
   273
lemma qsum_equal_iff: "A <+> B = C <+> D <-> A=C & B=D"
paulson@13285
   274
apply (simp (no_asm) add: extension qsum_subset_iff)
paulson@13285
   275
apply blast
paulson@13285
   276
done
paulson@13285
   277
paulson@13356
   278
subsubsection{*Eliminator -- qcase*}
paulson@13285
   279
paulson@13285
   280
lemma qcase_QInl [simp]: "qcase(c, d, QInl(a)) = c(a)"
paulson@13285
   281
by (simp add: qsum_defs )
paulson@13285
   282
paulson@13285
   283
paulson@13285
   284
lemma qcase_QInr [simp]: "qcase(c, d, QInr(b)) = d(b)"
paulson@13285
   285
by (simp add: qsum_defs )
paulson@13285
   286
paulson@13285
   287
lemma qcase_type:
paulson@13285
   288
    "[| u: A <+> B;  
paulson@13285
   289
        !!x. x: A ==> c(x): C(QInl(x));    
paulson@13285
   290
        !!y. y: B ==> d(y): C(QInr(y))  
paulson@13285
   291
     |] ==> qcase(c,d,u) : C(u)"
paulson@13784
   292
by (simp add: qsum_defs, auto) 
paulson@13285
   293
paulson@13285
   294
(** Rules for the Part primitive **)
paulson@13285
   295
paulson@13285
   296
lemma Part_QInl: "Part(A <+> B,QInl) = {QInl(x). x: A}"
paulson@13285
   297
by blast
paulson@13285
   298
paulson@13285
   299
lemma Part_QInr: "Part(A <+> B,QInr) = {QInr(y). y: B}"
paulson@13285
   300
by blast
paulson@13285
   301
paulson@13285
   302
lemma Part_QInr2: "Part(A <+> B, %x. QInr(h(x))) = {QInr(y). y: Part(B,h)}"
paulson@13285
   303
by blast
clasohm@0
   304
paulson@13285
   305
lemma Part_qsum_equality: "C <= A <+> B ==> Part(C,QInl) Un Part(C,QInr) = C"
paulson@13285
   306
by blast
paulson@13285
   307
paulson@13285
   308
paulson@13356
   309
subsubsection{*Monotonicity*}
paulson@13285
   310
paulson@13285
   311
lemma QPair_mono: "[| a<=c;  b<=d |] ==> <a;b> <= <c;d>"
paulson@13285
   312
by (simp add: QPair_def sum_mono)
paulson@13285
   313
paulson@13285
   314
lemma QSigma_mono [rule_format]:
paulson@13285
   315
     "[| A<=C;  ALL x:A. B(x) <= D(x) |] ==> QSigma(A,B) <= QSigma(C,D)"
paulson@13285
   316
by blast
paulson@13285
   317
paulson@13285
   318
lemma QInl_mono: "a<=b ==> QInl(a) <= QInl(b)"
paulson@13285
   319
by (simp add: QInl_def subset_refl [THEN QPair_mono])
paulson@13285
   320
paulson@13285
   321
lemma QInr_mono: "a<=b ==> QInr(a) <= QInr(b)"
paulson@13285
   322
by (simp add: QInr_def subset_refl [THEN QPair_mono])
paulson@13285
   323
paulson@13285
   324
lemma qsum_mono: "[| A<=C;  B<=D |] ==> A <+> B <= C <+> D"
paulson@13285
   325
by blast
paulson@13285
   326
clasohm@0
   327
end