src/ZF/QPair.ML
author clasohm
Tue, 30 Jan 1996 13:42:57 +0100
changeset 1461 6bcb44e4d6e5
parent 1096 6c177c4c2127
child 2469 b50b8c0eec01
permissions -rw-r--r--
expanded tabs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
     1
(*  Title:      ZF/QPair.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
     6
For QPair.thy.  
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
Quine-inspired ordered pairs and disjoint sums, for non-well-founded data
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
structures in ZF.  Does not precisely follow Quine's construction.  Thanks
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
to Thomas Forster for suggesting this approach!
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
W. V. Quine, On Ordered Pairs and Relations, in Selected Logic Papers,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
1966.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
Many proofs are borrowed from pair.ML and sum.ML
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
Do we EVER have rank(a) < rank(<a;b>) ?  Perhaps if the latter rank
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
    is not a limit ordinal? 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
open QPair;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
(**** Quine ordered pairing ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
(** Lemmas for showing that <a;b> uniquely determines a and b **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    27
qed_goalw "QPair_iff" thy [QPair_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
    "<a;b> = <c;d> <-> a=c & b=d"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
 (fn _=> [rtac sum_equal_iff 1]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    31
bind_thm ("QPair_inject", (QPair_iff RS iffD1 RS conjE));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    33
qed_goal "QPair_inject1" thy "<a;b> = <c;d> ==> a=c"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  [ (rtac (major RS QPair_inject) 1), (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    37
qed_goal "QPair_inject2" thy "<a;b> = <c;d> ==> b=d"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
  [ (rtac (major RS QPair_inject) 1), (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
(*** QSigma: Disjoint union of a family of sets
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
     Generalizes Cartesian product ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    45
qed_goalw "QSigmaI" thy [QSigma_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
    "[| a:A;  b:B(a) |] ==> <a;b> : QSigma(A,B)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
 (fn prems=> [ (REPEAT (resolve_tac (prems@[singletonI,UN_I]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
(*The general elimination rule*)
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    50
qed_goalw "QSigmaE" thy [QSigma_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
    "[| c: QSigma(A,B);  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
\       !!x y.[| x:A;  y:B(x);  c=<x;y> |] ==> P \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
\    |] ==> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
  [ (cut_facts_tac [major] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
    (REPEAT (eresolve_tac [UN_E, singletonE] 1 ORELSE ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
(** Elimination rules for <a;b>:A*B -- introducing no eigenvariables **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
val QSigmaE2 = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
  rule_by_tactic (REPEAT_FIRST (etac QPair_inject ORELSE' bound_hyp_subst_tac)
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
    62
                  THEN prune_params_tac)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
      (read_instantiate [("c","<a;b>")] QSigmaE);  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    65
qed_goal "QSigmaD1" thy "<a;b> : QSigma(A,B) ==> a : A"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
  [ (rtac (major RS QSigmaE2) 1), (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    69
qed_goal "QSigmaD2" thy "<a;b> : QSigma(A,B) ==> b : B(a)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
  [ (rtac (major RS QSigmaE2) 1), (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
    73
val qpair_cs = ZF_cs addSIs [QSigmaI] addSEs [QSigmaE2, QSigmaE, QPair_inject];
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
    74
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
    75
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    76
qed_goalw "QSigma_cong" thy [QSigma_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
    "[| A=A';  !!x. x:A' ==> B(x)=B'(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
\    QSigma(A,B) = QSigma(A',B')"
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
    79
 (fn prems=> [ (simp_tac (ZF_ss addsimps prems) 1) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    81
qed_goal "QSigma_empty1" thy "QSigma(0,B) = 0"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    82
 (fn _ => [ (fast_tac (qpair_cs addIs [equalityI]) 1) ]);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    83
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    84
qed_goal "QSigma_empty2" thy "A <*> 0 = 0"
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
    85
 (fn _ => [ (fast_tac (qpair_cs addIs [equalityI]) 1) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    87
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    88
(*** Projections: qfst, qsnd ***)
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    89
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    90
qed_goalw "qfst_conv" thy [qfst_def] "qfst(<a;b>) = a"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    91
 (fn _=> 
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    92
  [ (fast_tac (qpair_cs addIs [the_equality]) 1) ]);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    93
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    94
qed_goalw "qsnd_conv" thy [qsnd_def] "qsnd(<a;b>) = b"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    95
 (fn _=> 
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    96
  [ (fast_tac (qpair_cs addIs [the_equality]) 1) ]);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    97
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    98
val qpair_ss = ZF_ss addsimps [qfst_conv,qsnd_conv];
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
    99
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   100
qed_goal "qfst_type" thy
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   101
    "!!p. p:QSigma(A,B) ==> qfst(p) : A"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   102
 (fn _=> [ (fast_tac (qpair_cs addss qpair_ss) 1) ]);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   103
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   104
qed_goal "qsnd_type" thy
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   105
    "!!p. p:QSigma(A,B) ==> qsnd(p) : B(qfst(p))"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   106
 (fn _=> [ (fast_tac (qpair_cs addss qpair_ss) 1) ]);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   107
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   108
goal thy "!!a A B. a: QSigma(A,B) ==> <qfst(a); qsnd(a)> = a";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   109
by (etac QSigmaE 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   110
by (asm_simp_tac qpair_ss 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   111
qed "QPair_qfst_qsnd_eq";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
(*** Eliminator - qsplit ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   116
(*A META-equality, so that it applies to higher types as well...*)
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   117
qed_goalw "qsplit" thy [qsplit_def]
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   118
    "qsplit(%x y.c(x,y), <a;b>) == c(a,b)"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   119
 (fn _ => [ (simp_tac qpair_ss 1),
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   120
            (rtac reflexive_thm 1) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   122
qed_goal "qsplit_type" thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
    "[|  p:QSigma(A,B);   \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
\        !!x y.[| x:A; y:B(x) |] ==> c(x,y):C(<x;y>) \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
\    |] ==> qsplit(%x y.c(x,y), p) : C(p)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
  [ (rtac (major RS QSigmaE) 1),
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   128
    (asm_simp_tac (qpair_ss addsimps (qsplit::prems)) 1) ]);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   129
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   130
goalw thy [qsplit_def]
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   131
  "!!u. u: A<*>B ==>   \
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   132
\       R(qsplit(c,u)) <-> (ALL x:A. ALL y:B. u = <x;y> --> R(c(x,y)))";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   133
by (etac QSigmaE 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   134
by (asm_simp_tac qpair_ss 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   135
by (fast_tac qpair_cs 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   136
qed "expand_qsplit";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   137
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   138
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   139
(*** qsplit for predicates: result type o ***)
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   140
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   141
goalw thy [qsplit_def] "!!R a b. R(a,b) ==> qsplit(R, <a;b>)";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   142
by (asm_simp_tac qpair_ss 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   143
qed "qsplitI";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   144
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   145
val major::sigma::prems = goalw thy [qsplit_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
   146
    "[| qsplit(R,z);  z:QSigma(A,B);                    \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
   147
\       !!x y. [| z = <x;y>;  R(x,y) |] ==> P           \
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   148
\   |] ==> P";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   149
by (rtac (sigma RS QSigmaE) 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   150
by (cut_facts_tac [major] 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   151
by (asm_full_simp_tac (qpair_ss addsimps prems) 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   152
qed "qsplitE";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   153
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   154
goalw thy [qsplit_def] "!!R a b. qsplit(R,<a;b>) ==> R(a,b)";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   155
by (asm_full_simp_tac qpair_ss 1);
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   156
qed "qsplitD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
(*** qconverse ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   161
qed_goalw "qconverseI" thy [qconverse_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
    "!!a b r. <a;b>:r ==> <b;a>:qconverse(r)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
 (fn _ => [ (fast_tac qpair_cs 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   164
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   165
qed_goalw "qconverseD" thy [qconverse_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
    "!!a b r. <a;b> : qconverse(r) ==> <b;a> : r"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
 (fn _ => [ (fast_tac qpair_cs 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   169
qed_goalw "qconverseE" thy [qconverse_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
    "[| yx : qconverse(r);  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
\       !!x y. [| yx=<y;x>;  <x;y>:r |] ==> P \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
\    |] ==> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
 (fn [major,minor]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
  [ (rtac (major RS ReplaceE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
    (REPEAT (eresolve_tac [exE, conjE, minor] 1)),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
    (hyp_subst_tac 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
    (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
val qconverse_cs = qpair_cs addSIs [qconverseI] 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
   180
                            addSEs [qconverseD,qconverseE];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   182
qed_goal "qconverse_qconverse" thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
    "!!A B r. r<=QSigma(A,B) ==> qconverse(qconverse(r)) = r"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
 (fn _ => [ (fast_tac (qconverse_cs addSIs [equalityI]) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   185
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   186
qed_goal "qconverse_type" thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
    "!!A B r. r <= A <*> B ==> qconverse(r) <= B <*> A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
 (fn _ => [ (fast_tac qconverse_cs 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   190
qed_goal "qconverse_prod" thy "qconverse(A <*> B) = B <*> A"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
 (fn _ => [ (fast_tac (qconverse_cs addSIs [equalityI]) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   193
qed_goal "qconverse_empty" thy "qconverse(0) = 0"
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   194
 (fn _ => [ (fast_tac (qconverse_cs addSIs [equalityI]) 1) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
(**** The Quine-inspired notion of disjoint sum ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
val qsum_defs = [qsum_def,QInl_def,QInr_def,qcase_def];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
(** Introduction rules for the injections **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   203
goalw thy qsum_defs "!!a A B. a : A ==> QInl(a) : A <+> B";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
by (REPEAT (ares_tac [UnI1,QSigmaI,singletonI] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   205
qed "QInlI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   207
goalw thy qsum_defs "!!b A B. b : B ==> QInr(b) : A <+> B";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
by (REPEAT (ares_tac [UnI2,QSigmaI,singletonI] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   209
qed "QInrI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
(** Elimination rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   213
val major::prems = goalw thy qsum_defs
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
    "[| u: A <+> B;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
\       !!x. [| x:A;  u=QInl(x) |] ==> P; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
\       !!y. [| y:B;  u=QInr(y) |] ==> P \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
\    |] ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
by (rtac (major RS UnE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
by (REPEAT (rtac refl 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
     ORELSE eresolve_tac (prems@[QSigmaE,singletonE,ssubst]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   221
qed "qsumE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
(** Injection and freeness equivalences, for rewriting **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   225
goalw thy qsum_defs "QInl(a)=QInl(b) <-> a=b";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   226
by (simp_tac (ZF_ss addsimps [QPair_iff]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   227
qed "QInl_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   229
goalw thy qsum_defs "QInr(a)=QInr(b) <-> a=b";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   230
by (simp_tac (ZF_ss addsimps [QPair_iff]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   231
qed "QInr_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   233
goalw thy qsum_defs "QInl(a)=QInr(b) <-> False";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   234
by (simp_tac (ZF_ss addsimps [QPair_iff, one_not_0 RS not_sym]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   235
qed "QInl_QInr_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   237
goalw thy qsum_defs "QInr(b)=QInl(a) <-> False";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   238
by (simp_tac (ZF_ss addsimps [QPair_iff, one_not_0]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   239
qed "QInr_QInl_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   241
(*Injection and freeness rules*)
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   242
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   243
bind_thm ("QInl_inject", (QInl_iff RS iffD1));
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   244
bind_thm ("QInr_inject", (QInr_iff RS iffD1));
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   245
bind_thm ("QInl_neq_QInr", (QInl_QInr_iff RS iffD1 RS FalseE));
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   246
bind_thm ("QInr_neq_QInl", (QInr_QInl_iff RS iffD1 RS FalseE));
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   247
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
val qsum_cs = 
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   249
    qpair_cs addSIs [PartI, QInlI, QInrI] 
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   250
             addSEs [PartE, qsumE, QInl_neq_QInr, QInr_neq_QInl]
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   251
             addSDs [QInl_inject, QInr_inject];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   253
goal thy "!!A B. QInl(a): A<+>B ==> a: A";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   254
by (fast_tac qsum_cs 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   255
qed "QInlD";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   256
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   257
goal thy "!!A B. QInr(b): A<+>B ==> b: B";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   258
by (fast_tac qsum_cs 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   259
qed "QInrD";
55
331d93292ee0 ZF/ind-syntax/refl_thin: new
lcp
parents: 6
diff changeset
   260
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
(** <+> is itself injective... who cares?? **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   263
goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
    "u: A <+> B <-> (EX x. x:A & u=QInl(x)) | (EX y. y:B & u=QInr(y))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
by (fast_tac qsum_cs 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   266
qed "qsum_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   268
goal thy "A <+> B <= C <+> D <-> A<=C & B<=D";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
by (fast_tac qsum_cs 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   270
qed "qsum_subset_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   271
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   272
goal thy "A <+> B = C <+> D <-> A=C & B=D";
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   273
by (simp_tac (ZF_ss addsimps [extension,qsum_subset_iff]) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
by (fast_tac ZF_cs 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   275
qed "qsum_equal_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
(*** Eliminator -- qcase ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   279
goalw thy qsum_defs "qcase(c, d, QInl(a)) = c(a)";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   280
by (simp_tac (ZF_ss addsimps [qsplit, cond_0]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   281
qed "qcase_QInl";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   283
goalw thy qsum_defs "qcase(c, d, QInr(b)) = d(b)";
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   284
by (simp_tac (ZF_ss addsimps [qsplit, cond_1]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   285
qed "qcase_QInr";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   287
val major::prems = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
    "[| u: A <+> B; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
\       !!x. x: A ==> c(x): C(QInl(x));   \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
\       !!y. y: B ==> d(y): C(QInr(y)) \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
\    |] ==> qcase(c,d,u) : C(u)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
by (rtac (major RS qsumE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
by (ALLGOALS (etac ssubst));
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   294
by (ALLGOALS (asm_simp_tac (ZF_ss addsimps
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1096
diff changeset
   295
                            (prems@[qcase_QInl,qcase_QInr]))));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   296
qed "qcase_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
(** Rules for the Part primitive **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   300
goal thy "Part(A <+> B,QInl) = {QInl(x). x: A}";
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   301
by (fast_tac (qsum_cs addIs [equalityI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   302
qed "Part_QInl";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   304
goal thy "Part(A <+> B,QInr) = {QInr(y). y: B}";
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   305
by (fast_tac (qsum_cs addIs [equalityI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   306
qed "Part_QInr";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   308
goal thy "Part(A <+> B, %x.QInr(h(x))) = {QInr(y). y: Part(B,h)}";
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   309
by (fast_tac (qsum_cs addIs [equalityI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   310
qed "Part_QInr2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
1096
6c177c4c2127 Modified proofs for (q)split, fst, snd for new
lcp
parents: 790
diff changeset
   312
goal thy "!!A B C. C <= A <+> B ==> Part(C,QInl) Un Part(C,QInr) = C";
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 516
diff changeset
   313
by (fast_tac (qsum_cs addIs [equalityI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   314
qed "Part_qsum_equality";