src/ZF/Pair.ML
author clasohm
Thu Sep 16 12:20:38 1993 +0200 (1993-09-16)
changeset 0 a5a9c433f639
child 6 8ce8c4d13d4d
permissions -rw-r--r--
Initial revision
clasohm@0
     1
(*  Title: 	ZF/pair
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1992  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Ordered pairs in Zermelo-Fraenkel Set Theory 
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
(** Lemmas for showing that <a,b> uniquely determines a and b **)
clasohm@0
    10
clasohm@0
    11
val doubleton_iff = prove_goal ZF.thy
clasohm@0
    12
    "{a,b} = {c,d} <-> (a=c & b=d) | (a=d & b=c)"
clasohm@0
    13
 (fn _=> [ (resolve_tac [extension RS iff_trans] 1),
clasohm@0
    14
           (fast_tac upair_cs 1) ]);
clasohm@0
    15
clasohm@0
    16
val Pair_iff = prove_goalw ZF.thy [Pair_def]
clasohm@0
    17
    "<a,b> = <c,d> <-> a=c & b=d"
clasohm@0
    18
 (fn _=> [ (SIMP_TAC (FOL_ss addrews [doubleton_iff]) 1),
clasohm@0
    19
           (fast_tac FOL_cs 1) ]);
clasohm@0
    20
clasohm@0
    21
val Pair_inject = standard (Pair_iff RS iffD1 RS conjE);
clasohm@0
    22
clasohm@0
    23
val Pair_inject1 = prove_goal ZF.thy "<a,b> = <c,d> ==> a=c"
clasohm@0
    24
 (fn [major]=>
clasohm@0
    25
  [ (rtac (major RS Pair_inject) 1), (assume_tac 1) ]);
clasohm@0
    26
clasohm@0
    27
val Pair_inject2 = prove_goal ZF.thy "<a,b> = <c,d> ==> b=d"
clasohm@0
    28
 (fn [major]=>
clasohm@0
    29
  [ (rtac (major RS Pair_inject) 1), (assume_tac 1) ]);
clasohm@0
    30
clasohm@0
    31
val Pair_neq_0 = prove_goalw ZF.thy [Pair_def] "<a,b>=0 ==> P"
clasohm@0
    32
 (fn [major]=>
clasohm@0
    33
  [ (rtac (major RS equalityD1 RS subsetD RS emptyE) 1),
clasohm@0
    34
    (rtac consI1 1) ]);
clasohm@0
    35
clasohm@0
    36
val Pair_neq_fst = prove_goalw ZF.thy [Pair_def] "<a,b>=a ==> P"
clasohm@0
    37
 (fn [major]=>
clasohm@0
    38
  [ (rtac (consI1 RS mem_anti_sym RS FalseE) 1),
clasohm@0
    39
    (rtac (major RS subst) 1),
clasohm@0
    40
    (rtac consI1 1) ]);
clasohm@0
    41
clasohm@0
    42
val Pair_neq_snd = prove_goalw ZF.thy [Pair_def] "<a,b>=b ==> P"
clasohm@0
    43
 (fn [major]=>
clasohm@0
    44
  [ (rtac (consI1 RS consI2 RS mem_anti_sym RS FalseE) 1),
clasohm@0
    45
    (rtac (major RS subst) 1),
clasohm@0
    46
    (rtac (consI1 RS consI2) 1) ]);
clasohm@0
    47
clasohm@0
    48
clasohm@0
    49
(*** Sigma: Disjoint union of a family of sets
clasohm@0
    50
     Generalizes Cartesian product ***)
clasohm@0
    51
clasohm@0
    52
val SigmaI = prove_goalw ZF.thy [Sigma_def]
clasohm@0
    53
    "[| a:A;  b:B(a) |] ==> <a,b> : Sigma(A,B)"
clasohm@0
    54
 (fn prems=> [ (REPEAT (resolve_tac (prems@[singletonI,UN_I]) 1)) ]);
clasohm@0
    55
clasohm@0
    56
(*The general elimination rule*)
clasohm@0
    57
val SigmaE = prove_goalw ZF.thy [Sigma_def]
clasohm@0
    58
    "[| c: Sigma(A,B);  \
clasohm@0
    59
\       !!x y.[| x:A;  y:B(x);  c=<x,y> |] ==> P \
clasohm@0
    60
\    |] ==> P"
clasohm@0
    61
 (fn major::prems=>
clasohm@0
    62
  [ (cut_facts_tac [major] 1),
clasohm@0
    63
    (REPEAT (eresolve_tac [UN_E, singletonE] 1 ORELSE ares_tac prems 1)) ]);
clasohm@0
    64
clasohm@0
    65
(** Elimination of <a,b>:A*B -- introduces no eigenvariables **)
clasohm@0
    66
val SigmaD1 = prove_goal ZF.thy "<a,b> : Sigma(A,B) ==> a : A"
clasohm@0
    67
 (fn [major]=>
clasohm@0
    68
  [ (rtac (major RS SigmaE) 1),
clasohm@0
    69
    (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ]);
clasohm@0
    70
clasohm@0
    71
val SigmaD2 = prove_goal ZF.thy "<a,b> : Sigma(A,B) ==> b : B(a)"
clasohm@0
    72
 (fn [major]=>
clasohm@0
    73
  [ (rtac (major RS SigmaE) 1),
clasohm@0
    74
    (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ]);
clasohm@0
    75
clasohm@0
    76
(*Also provable via 
clasohm@0
    77
  rule_by_tactic (REPEAT_FIRST (etac Pair_inject ORELSE' bound_hyp_subst_tac)
clasohm@0
    78
		  THEN prune_params_tac)
clasohm@0
    79
      (read_instantiate [("c","<a,b>")] SigmaE);  *)
clasohm@0
    80
val SigmaE2 = prove_goal ZF.thy
clasohm@0
    81
    "[| <a,b> : Sigma(A,B);    \
clasohm@0
    82
\       [| a:A;  b:B(a) |] ==> P   \
clasohm@0
    83
\    |] ==> P"
clasohm@0
    84
 (fn [major,minor]=>
clasohm@0
    85
  [ (rtac minor 1),
clasohm@0
    86
    (rtac (major RS SigmaD1) 1),
clasohm@0
    87
    (rtac (major RS SigmaD2) 1) ]);
clasohm@0
    88
clasohm@0
    89
val Sigma_cong = prove_goalw ZF.thy [Sigma_def]
clasohm@0
    90
    "[| A=A';  !!x. x:A' ==> B(x)=B'(x) |] ==> \
clasohm@0
    91
\    Sigma(A,B) = Sigma(A',B')"
clasohm@0
    92
 (fn prems=> [ (prove_cong_tac (prems@[RepFun_cong]) 1) ]);
clasohm@0
    93
clasohm@0
    94
val Sigma_empty1 = prove_goal ZF.thy "Sigma(0,B) = 0"
clasohm@0
    95
 (fn _ => [ (fast_tac (lemmas_cs addIs [equalityI] addSEs [SigmaE]) 1) ]);
clasohm@0
    96
clasohm@0
    97
val Sigma_empty2 = prove_goal ZF.thy "A*0 = 0"
clasohm@0
    98
 (fn _ => [ (fast_tac (lemmas_cs addIs [equalityI] addSEs [SigmaE]) 1) ]);
clasohm@0
    99
clasohm@0
   100
clasohm@0
   101
(*** Eliminator - split ***)
clasohm@0
   102
clasohm@0
   103
val split = prove_goalw ZF.thy [split_def]
clasohm@0
   104
    "split(%x y.c(x,y), <a,b>) = c(a,b)"
clasohm@0
   105
 (fn _ =>
clasohm@0
   106
  [ (fast_tac (upair_cs addIs [the_equality] addEs [Pair_inject]) 1) ]);
clasohm@0
   107
clasohm@0
   108
val split_type = prove_goal ZF.thy
clasohm@0
   109
    "[|  p:Sigma(A,B);   \
clasohm@0
   110
\        !!x y.[| x:A; y:B(x) |] ==> c(x,y):C(<x,y>) \
clasohm@0
   111
\    |] ==> split(%x y.c(x,y), p) : C(p)"
clasohm@0
   112
 (fn major::prems=>
clasohm@0
   113
  [ (rtac (major RS SigmaE) 1),
clasohm@0
   114
    (etac ssubst 1),
clasohm@0
   115
    (REPEAT (ares_tac (prems @ [split RS ssubst]) 1)) ]);
clasohm@0
   116
clasohm@0
   117
(*This congruence rule uses NO typing information...*)
clasohm@0
   118
val split_cong = prove_goalw ZF.thy [split_def] 
clasohm@0
   119
    "[| p=p';  !!x y.c(x,y) = c'(x,y) |] ==> \
clasohm@0
   120
\    split(%x y.c(x,y), p) = split(%x y.c'(x,y), p')"
clasohm@0
   121
 (fn prems=> [ (prove_cong_tac (prems@[the_cong]) 1) ]);
clasohm@0
   122
clasohm@0
   123
clasohm@0
   124
(*** conversions for fst and snd ***)
clasohm@0
   125
clasohm@0
   126
val fst_conv = prove_goalw ZF.thy [fst_def] "fst(<a,b>) = a"
clasohm@0
   127
 (fn _=> [ (rtac split 1) ]);
clasohm@0
   128
clasohm@0
   129
val snd_conv = prove_goalw ZF.thy [snd_def] "snd(<a,b>) = b"
clasohm@0
   130
 (fn _=> [ (rtac split 1) ]);
clasohm@0
   131
clasohm@0
   132
clasohm@0
   133
(*** split for predicates: result type o ***)
clasohm@0
   134
clasohm@0
   135
goalw ZF.thy [fsplit_def] "!!R a b. R(a,b) ==> fsplit(R, <a,b>)";
clasohm@0
   136
by (REPEAT (ares_tac [refl,exI,conjI] 1));
clasohm@0
   137
val fsplitI = result();
clasohm@0
   138
clasohm@0
   139
val major::prems = goalw ZF.thy [fsplit_def]
clasohm@0
   140
    "[| fsplit(R,z);  !!x y. [| z = <x,y>;  R(x,y) |] ==> P |] ==> P";
clasohm@0
   141
by (cut_facts_tac [major] 1);
clasohm@0
   142
by (REPEAT (eresolve_tac (prems@[asm_rl,exE,conjE]) 1));
clasohm@0
   143
val fsplitE = result();
clasohm@0
   144
clasohm@0
   145
goal ZF.thy "!!R a b. fsplit(R,<a,b>) ==> R(a,b)";
clasohm@0
   146
by (REPEAT (eresolve_tac [asm_rl,fsplitE,Pair_inject,ssubst] 1));
clasohm@0
   147
val fsplitD = result();
clasohm@0
   148
clasohm@0
   149
val pair_cs = upair_cs 
clasohm@0
   150
    addSIs [SigmaI]
clasohm@0
   151
    addSEs [SigmaE2, SigmaE, Pair_inject, make_elim succ_inject,
clasohm@0
   152
	    Pair_neq_0, sym RS Pair_neq_0, succ_neq_0, sym RS succ_neq_0];
clasohm@0
   153