src/ZF/Trancl.ML
author paulson
Wed Apr 23 10:54:22 1997 +0200 (1997-04-23)
changeset 3016 15763781afb0
parent 2929 4eefc6c22d41
child 4091 771b1f6422a8
permissions -rw-r--r--
Conversion to use blast_tac
clasohm@1461
     1
(*  Title:      ZF/trancl.ML
clasohm@0
     2
    ID:         $Id$
clasohm@1461
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1992  University of Cambridge
clasohm@0
     5
paulson@2929
     6
Transitive closure of a relation
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
open Trancl;
clasohm@0
    10
clasohm@0
    11
goal Trancl.thy "bnd_mono(field(r)*field(r), %s. id(field(r)) Un (r O s))";
clasohm@0
    12
by (rtac bnd_monoI 1);
clasohm@0
    13
by (REPEAT (ares_tac [subset_refl, Un_mono, comp_mono] 2));
paulson@2929
    14
by (Blast_tac 1);
clasohm@760
    15
qed "rtrancl_bnd_mono";
clasohm@0
    16
clasohm@0
    17
val [prem] = goalw Trancl.thy [rtrancl_def] "r<=s ==> r^* <= s^*";
clasohm@0
    18
by (rtac lfp_mono 1);
clasohm@0
    19
by (REPEAT (resolve_tac [rtrancl_bnd_mono, prem, subset_refl, id_mono,
clasohm@1461
    20
                         comp_mono, Un_mono, field_mono, Sigma_mono] 1));
clasohm@760
    21
qed "rtrancl_mono";
clasohm@0
    22
clasohm@0
    23
(* r^* = id(field(r)) Un ( r O r^* )    *)
clasohm@0
    24
val rtrancl_unfold = rtrancl_bnd_mono RS (rtrancl_def RS def_lfp_Tarski);
clasohm@0
    25
clasohm@0
    26
(** The relation rtrancl **)
clasohm@0
    27
clasohm@782
    28
bind_thm ("rtrancl_type", (rtrancl_def RS def_lfp_subset));
clasohm@0
    29
clasohm@0
    30
(*Reflexivity of rtrancl*)
clasohm@0
    31
val [prem] = goal Trancl.thy "[| a: field(r) |] ==> <a,a> : r^*";
clasohm@0
    32
by (resolve_tac [rtrancl_unfold RS ssubst] 1);
clasohm@0
    33
by (rtac (prem RS idI RS UnI1) 1);
clasohm@760
    34
qed "rtrancl_refl";
clasohm@0
    35
clasohm@0
    36
(*Closure under composition with r  *)
clasohm@0
    37
val prems = goal Trancl.thy
clasohm@0
    38
    "[| <a,b> : r^*;  <b,c> : r |] ==> <a,c> : r^*";
clasohm@0
    39
by (resolve_tac [rtrancl_unfold RS ssubst] 1);
clasohm@0
    40
by (rtac (compI RS UnI2) 1);
clasohm@0
    41
by (resolve_tac prems 1);
clasohm@0
    42
by (resolve_tac prems 1);
clasohm@760
    43
qed "rtrancl_into_rtrancl";
clasohm@0
    44
clasohm@0
    45
(*rtrancl of r contains all pairs in r  *)
clasohm@0
    46
val prems = goal Trancl.thy "<a,b> : r ==> <a,b> : r^*";
clasohm@0
    47
by (resolve_tac [rtrancl_refl RS rtrancl_into_rtrancl] 1);
clasohm@0
    48
by (REPEAT (resolve_tac (prems@[fieldI1]) 1));
clasohm@760
    49
qed "r_into_rtrancl";
clasohm@0
    50
clasohm@0
    51
(*The premise ensures that r consists entirely of pairs*)
clasohm@0
    52
val prems = goal Trancl.thy "r <= Sigma(A,B) ==> r <= r^*";
clasohm@0
    53
by (cut_facts_tac prems 1);
paulson@2929
    54
by (blast_tac (!claset addIs [r_into_rtrancl]) 1);
clasohm@760
    55
qed "r_subset_rtrancl";
clasohm@0
    56
clasohm@0
    57
goal Trancl.thy "field(r^*) = field(r)";
paulson@2929
    58
by (blast_tac (!claset addIs [r_into_rtrancl] 
clasohm@1461
    59
                    addSDs [rtrancl_type RS subsetD]) 1);
clasohm@760
    60
qed "rtrancl_field";
clasohm@0
    61
clasohm@0
    62
clasohm@0
    63
(** standard induction rule **)
clasohm@0
    64
clasohm@0
    65
val major::prems = goal Trancl.thy
clasohm@0
    66
  "[| <a,b> : r^*; \
clasohm@0
    67
\     !!x. x: field(r) ==> P(<x,x>); \
clasohm@0
    68
\     !!x y z.[| P(<x,y>); <x,y>: r^*; <y,z>: r |]  ==>  P(<x,z>) |] \
clasohm@0
    69
\  ==>  P(<a,b>)";
clasohm@0
    70
by (rtac ([rtrancl_def, rtrancl_bnd_mono, major] MRS def_induct) 1);
paulson@3016
    71
by (blast_tac (!claset addIs prems) 1);
clasohm@760
    72
qed "rtrancl_full_induct";
clasohm@0
    73
clasohm@0
    74
(*nice induction rule.
clasohm@0
    75
  Tried adding the typing hypotheses y,z:field(r), but these
clasohm@0
    76
  caused expensive case splits!*)
clasohm@0
    77
val major::prems = goal Trancl.thy
clasohm@1461
    78
  "[| <a,b> : r^*;                                              \
clasohm@1461
    79
\     P(a);                                                     \
clasohm@1461
    80
\     !!y z.[| <a,y> : r^*;  <y,z> : r;  P(y) |] ==> P(z)       \
clasohm@0
    81
\  |] ==> P(b)";
clasohm@0
    82
(*by induction on this formula*)
clasohm@0
    83
by (subgoal_tac "ALL y. <a,b> = <a,y> --> P(y)" 1);
clasohm@0
    84
(*now solve first subgoal: this formula is sufficient*)
clasohm@0
    85
by (EVERY1 [etac (spec RS mp), rtac refl]);
clasohm@0
    86
(*now do the induction*)
clasohm@0
    87
by (resolve_tac [major RS rtrancl_full_induct] 1);
paulson@3016
    88
by (ALLGOALS (blast_tac (!claset addIs prems)));
clasohm@760
    89
qed "rtrancl_induct";
clasohm@0
    90
clasohm@0
    91
(*transitivity of transitive closure!! -- by induction.*)
clasohm@0
    92
goalw Trancl.thy [trans_def] "trans(r^*)";
clasohm@0
    93
by (REPEAT (resolve_tac [allI,impI] 1));
clasohm@0
    94
by (eres_inst_tac [("b","z")] rtrancl_induct 1);
clasohm@0
    95
by (DEPTH_SOLVE (eresolve_tac [asm_rl, rtrancl_into_rtrancl] 1));
clasohm@760
    96
qed "trans_rtrancl";
clasohm@0
    97
clasohm@0
    98
(*elimination of rtrancl -- by induction on a special formula*)
clasohm@0
    99
val major::prems = goal Trancl.thy
clasohm@1461
   100
    "[| <a,b> : r^*;  (a=b) ==> P;                       \
clasohm@1461
   101
\       !!y.[| <a,y> : r^*;   <y,b> : r |] ==> P |]      \
clasohm@0
   102
\    ==> P";
clasohm@0
   103
by (subgoal_tac "a = b  | (EX y. <a,y> : r^* & <y,b> : r)" 1);
clasohm@0
   104
(*see HOL/trancl*)
clasohm@0
   105
by (rtac (major RS rtrancl_induct) 2);
paulson@2469
   106
by (ALLGOALS (fast_tac (!claset addSEs prems)));
clasohm@760
   107
qed "rtranclE";
clasohm@0
   108
clasohm@0
   109
clasohm@0
   110
(**** The relation trancl ****)
clasohm@0
   111
clasohm@0
   112
(*Transitivity of r^+ is proved by transitivity of r^*  *)
clasohm@0
   113
goalw Trancl.thy [trans_def,trancl_def] "trans(r^+)";
paulson@3016
   114
by (blast_tac (!claset addIs [rtrancl_into_rtrancl RS 
paulson@3016
   115
			      (trans_rtrancl RS transD RS compI)]) 1);
clasohm@760
   116
qed "trans_trancl";
clasohm@0
   117
clasohm@0
   118
(** Conversions between trancl and rtrancl **)
clasohm@0
   119
paulson@3016
   120
goalw Trancl.thy [trancl_def] "!!r. <a,b> : r^+ ==> <a,b> : r^*";
paulson@3016
   121
by (blast_tac (!claset addIs [rtrancl_into_rtrancl]) 1);
clasohm@760
   122
qed "trancl_into_rtrancl";
clasohm@0
   123
clasohm@0
   124
(*r^+ contains all pairs in r  *)
paulson@3016
   125
goalw Trancl.thy [trancl_def] "!!r. <a,b> : r ==> <a,b> : r^+";
paulson@3016
   126
by (blast_tac (!claset addSIs [rtrancl_refl]) 1);
clasohm@760
   127
qed "r_into_trancl";
clasohm@0
   128
clasohm@0
   129
(*The premise ensures that r consists entirely of pairs*)
paulson@3016
   130
goal Trancl.thy "!!r. r <= Sigma(A,B) ==> r <= r^+";
paulson@2929
   131
by (blast_tac (!claset addIs [r_into_trancl]) 1);
clasohm@760
   132
qed "r_subset_trancl";
clasohm@0
   133
clasohm@0
   134
(*intro rule by definition: from r^* and r  *)
paulson@3016
   135
goalw Trancl.thy [trancl_def]
paulson@3016
   136
    "!!r. [| <a,b> : r^*;  <b,c> : r |]   ==>  <a,c> : r^+";
paulson@3016
   137
by (Blast_tac 1);
clasohm@760
   138
qed "rtrancl_into_trancl1";
clasohm@0
   139
clasohm@0
   140
(*intro rule from r and r^*  *)
clasohm@0
   141
val prems = goal Trancl.thy
clasohm@0
   142
    "[| <a,b> : r;  <b,c> : r^* |]   ==>  <a,c> : r^+";
clasohm@0
   143
by (resolve_tac (prems RL [rtrancl_induct]) 1);
clasohm@0
   144
by (resolve_tac (prems RL [r_into_trancl]) 1);
clasohm@0
   145
by (etac (trans_trancl RS transD) 1);
clasohm@0
   146
by (etac r_into_trancl 1);
clasohm@760
   147
qed "rtrancl_into_trancl2";
clasohm@0
   148
clasohm@0
   149
(*Nice induction rule for trancl*)
clasohm@0
   150
val major::prems = goal Trancl.thy
clasohm@1461
   151
  "[| <a,b> : r^+;                                      \
clasohm@1461
   152
\     !!y.  [| <a,y> : r |] ==> P(y);                   \
clasohm@1461
   153
\     !!y z.[| <a,y> : r^+;  <y,z> : r;  P(y) |] ==> P(z)       \
clasohm@0
   154
\  |] ==> P(b)";
clasohm@0
   155
by (rtac (rewrite_rule [trancl_def] major  RS  compEpair) 1);
clasohm@0
   156
(*by induction on this formula*)
clasohm@0
   157
by (subgoal_tac "ALL z. <y,z> : r --> P(z)" 1);
clasohm@0
   158
(*now solve first subgoal: this formula is sufficient*)
paulson@2929
   159
by (Blast_tac 1);
clasohm@0
   160
by (etac rtrancl_induct 1);
paulson@2469
   161
by (ALLGOALS (fast_tac (!claset addIs (rtrancl_into_trancl1::prems))));
clasohm@760
   162
qed "trancl_induct";
clasohm@0
   163
clasohm@0
   164
(*elimination of r^+ -- NOT an induction rule*)
clasohm@0
   165
val major::prems = goal Trancl.thy
clasohm@0
   166
    "[| <a,b> : r^+;  \
clasohm@0
   167
\       <a,b> : r ==> P; \
clasohm@1461
   168
\       !!y.[| <a,y> : r^+; <y,b> : r |] ==> P  \
clasohm@0
   169
\    |] ==> P";
clasohm@0
   170
by (subgoal_tac "<a,b> : r | (EX y. <a,y> : r^+  &  <y,b> : r)" 1);
paulson@2469
   171
by (fast_tac (!claset addIs prems) 1);
clasohm@0
   172
by (rtac (rewrite_rule [trancl_def] major RS compEpair) 1);
clasohm@0
   173
by (etac rtranclE 1);
paulson@2929
   174
by (ALLGOALS (blast_tac (!claset addIs [rtrancl_into_trancl1])));
clasohm@760
   175
qed "tranclE";
clasohm@0
   176
clasohm@0
   177
goalw Trancl.thy [trancl_def] "r^+ <= field(r)*field(r)";
paulson@2929
   178
by (blast_tac (!claset addEs [rtrancl_type RS subsetD RS SigmaE2]) 1);
clasohm@760
   179
qed "trancl_type";
clasohm@0
   180
clasohm@0
   181
val [prem] = goalw Trancl.thy [trancl_def] "r<=s ==> r^+ <= s^+";
clasohm@0
   182
by (REPEAT (resolve_tac [prem, comp_mono, rtrancl_mono] 1));
clasohm@760
   183
qed "trancl_mono";
clasohm@0
   184