src/HOL/Trancl.ML
author berghofe
Thu, 23 May 1996 14:37:06 +0200
changeset 1760 6f41a494f3b1
parent 1746 f0c6aabc6c02
child 1766 23922221ac87
permissions -rw-r--r--
Replaced fast_tac by Fast_tac (which uses default claset) New rules are now also added to default claset.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1301
diff changeset
     1
(*  Title:      HOL/trancl
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1301
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
For trancl.thy.  Theorems about the transitive closure of a relation
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open Trancl;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
(** The relation rtrancl **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
goal Trancl.thy "mono(%s. id Un (r O s))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
by (rtac monoI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
by (REPEAT (ares_tac [monoI, subset_refl, comp_mono, Un_mono] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
qed "rtrancl_fun_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
val rtrancl_unfold = rtrancl_fun_mono RS (rtrancl_def RS def_lfp_Tarski);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
(*Reflexivity of rtrancl*)
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    21
goal Trancl.thy "(a,a) : r^*";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
by (stac rtrancl_unfold 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    23
by (Fast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
qed "rtrancl_refl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
(*Closure under composition with r*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
val prems = goal Trancl.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    28
    "[| (a,b) : r^*;  (b,c) : r |] ==> (a,c) : r^*";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
by (stac rtrancl_unfold 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    30
by (fast_tac (!claset addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
qed "rtrancl_into_rtrancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
(*rtrancl of r contains r*)
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1130
diff changeset
    34
goal Trancl.thy "!!p. p : r ==> p : r^*";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1496
diff changeset
    35
by (split_all_tac 1);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1130
diff changeset
    36
by (etac (rtrancl_refl RS rtrancl_into_rtrancl) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
qed "r_into_rtrancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
(*monotonicity of rtrancl*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
goalw Trancl.thy [rtrancl_def] "!!r s. r <= s ==> r^* <= s^*";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1496
diff changeset
    41
by (REPEAT(ares_tac [lfp_mono,Un_mono,comp_mono,subset_refl] 1));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
qed "rtrancl_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
(** standard induction rule **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
val major::prems = goal Trancl.thy 
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    47
  "[| (a,b) : r^*; \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    48
\     !!x. P((x,x)); \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    49
\     !!x y z.[| P((x,y)); (x,y): r^*; (y,z): r |]  ==>  P((x,z)) |] \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    50
\  ==>  P((a,b))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
by (rtac ([rtrancl_def, rtrancl_fun_mono, major] MRS def_induct) 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    52
by (fast_tac (!claset addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
qed "rtrancl_full_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
(*nice induction rule*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
val major::prems = goal Trancl.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    57
    "[| (a::'a,b) : r^*;    \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
\       P(a); \
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1301
diff changeset
    59
\       !!y z.[| (a,y) : r^*;  (y,z) : r;  P(y) |] ==> P(z) |]  \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
\     ==> P(b)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
(*by induction on this formula*)
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    62
by (subgoal_tac "! y. (a::'a,b) = (a,y) --> P(y)" 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
(*now solve first subgoal: this formula is sufficient*)
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    64
by (Fast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
(*now do the induction*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
by (resolve_tac [major RS rtrancl_full_induct] 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    67
by (fast_tac (!claset addIs prems) 1);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    68
by (fast_tac (!claset addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
qed "rtrancl_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1706
diff changeset
    71
bind_thm
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1706
diff changeset
    72
  ("rtrancl_induct2",
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1706
diff changeset
    73
   Prod_Syntax.split_rule
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1706
diff changeset
    74
     (read_instantiate [("a","(ax,ay)"), ("b","(bx,by)")] rtrancl_induct));
1706
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
    75
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
(*transitivity of transitive closure!! -- by induction.*)
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    77
goalw Trancl.thy [trans_def] "trans(r^*)";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    78
by (safe_tac HOL_cs);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    79
by (eres_inst_tac [("b","z")] rtrancl_induct 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    80
by (ALLGOALS(fast_tac (!claset addIs [rtrancl_into_rtrancl])));
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    81
qed "trans_rtrancl";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    82
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    83
bind_thm ("rtrancl_trans", trans_rtrancl RS transD);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    84
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
(*elimination of rtrancl -- by induction on a special formula*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
val major::prems = goal Trancl.thy
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1301
diff changeset
    88
    "[| (a::'a,b) : r^*;  (a = b) ==> P;        \
5d7a7e439cec expanded tabs
clasohm
parents: 1301
diff changeset
    89
\       !!y.[| (a,y) : r^*; (y,b) : r |] ==> P  \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
\    |] ==> P";
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    91
by (subgoal_tac "(a::'a) = b  | (? y. (a,y) : r^* & (y,b) : r)" 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
by (rtac (major RS rtrancl_induct) 2);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    93
by (fast_tac (!claset addIs prems) 2);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
    94
by (fast_tac (!claset addIs prems) 2);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
by (REPEAT (eresolve_tac ([asm_rl,exE,disjE,conjE]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
qed "rtranclE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    98
bind_thm ("rtrancl_into_rtrancl2", r_into_rtrancl RS rtrancl_trans);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
    99
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   100
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   101
(*** More r^* equations and inclusions ***)
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   102
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   103
goal Trancl.thy "(r^*)^* = r^*";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   104
by (rtac set_ext 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   105
by (res_inst_tac [("p","x")] PairE 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   106
by (hyp_subst_tac 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   107
by (rtac iffI 1);
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1496
diff changeset
   108
by (etac rtrancl_induct 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   109
by (rtac rtrancl_refl 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   110
by (fast_tac (!claset addEs [rtrancl_trans]) 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   111
by (etac r_into_rtrancl 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   112
qed "rtrancl_idemp";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   113
Addsimps [rtrancl_idemp];
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   114
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   115
goal Trancl.thy "!!r s. r <= s^* ==> r^* <= s^*";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   116
bd rtrancl_mono 1;
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   117
by (Asm_full_simp_tac 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   118
qed "rtrancl_subset_rtrancl";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   119
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   120
goal Trancl.thy "!!R. [| R <= S; S <= R^* |] ==> S^* = R^*";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   121
by (dtac rtrancl_mono 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   122
by (dtac rtrancl_mono 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   123
by (Asm_full_simp_tac 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   124
by (Fast_tac 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   125
qed "rtrancl_subset";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   126
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   127
goal Trancl.thy "!!R. (R^* Un S^*)^* = (R Un S)^*";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   128
by (best_tac (set_cs addIs [rtrancl_subset,r_into_rtrancl,
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   129
                           rtrancl_mono RS subsetD]) 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   130
qed "rtrancl_Un_rtrancl";
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents: 1465
diff changeset
   131
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   132
goal Trancl.thy "(R^=)^* = R^*";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   133
by (fast_tac (rel_cs addIs [rtrancl_refl,rtrancl_subset,r_into_rtrancl]) 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   134
qed "rtrancl_reflcl";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   135
Addsimps [rtrancl_reflcl];
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   136
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   137
goal Trancl.thy "!!r. (x,y) : (converse r)^* ==> (x,y) : converse(r^*)";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   138
by (rtac converseI 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   139
by (etac rtrancl_induct 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   140
by (rtac rtrancl_refl 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   141
by (fast_tac (!claset addIs [r_into_rtrancl,rtrancl_trans]) 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   142
qed "rtrancl_converseD";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   143
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   144
goal Trancl.thy "!!r. (x,y) : converse(r^*) ==> (x,y) : (converse r)^*";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   145
by (dtac converseD 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   146
by (etac rtrancl_induct 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   147
by (rtac rtrancl_refl 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   148
by (fast_tac (!claset addIs [r_into_rtrancl,rtrancl_trans]) 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   149
qed "rtrancl_converseI";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   150
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   151
goal Trancl.thy "(converse r)^* = converse(r^*)";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   152
by (safe_tac (rel_eq_cs addSIs [rtrancl_converseI]));
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   153
by (res_inst_tac [("p","x")] PairE 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   154
by (hyp_subst_tac 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   155
by (etac rtrancl_converseD 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   156
qed "rtrancl_converse";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   157
1706
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   158
val major::prems = goal Trancl.thy
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   159
    "[| (a,b) : r^*; P(b); \
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   160
\       !!y z.[| (y,z) : r;  (z,b) : r^*;  P(z) |] ==> P(y) |]  \
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   161
\     ==> P(a)";
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   162
br ((major RS converseI RS rtrancl_converseI) RS rtrancl_induct) 1;
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   163
 brs prems 1;
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   164
by(fast_tac (!claset addIs prems addSEs[converseD]addSDs[rtrancl_converseD])1);
1706
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   165
qed "converse_rtrancl_induct";
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   166
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   167
val prems = goal Trancl.thy
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   168
 "[| ((a,b),(c,d)) : r^*; P c d; \
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   169
\    !!x y z u.[| ((x,y),(z,u)) : r;  ((z,u),(c,d)) : r^*;  P z u |] ==> P x y\
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   170
\ |] ==> P a b";
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   171
by(res_inst_tac[("R","P")]splitD 1);
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   172
by(res_inst_tac[("P","split P")]converse_rtrancl_induct 1);
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   173
brs prems 1;
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   174
by(Simp_tac 1);
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   175
brs prems 1;
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   176
by(split_all_tac 1);
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   177
by(Asm_full_simp_tac 1);
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   178
by(REPEAT(ares_tac prems 1));
4e0d5c7f57fa Added backwards rtrancl_induct and special versions for pairs.
nipkow
parents: 1642
diff changeset
   179
qed "converse_rtrancl_induct2";
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents: 1465
diff changeset
   180
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
(**** The relation trancl ****)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
(** Conversions between trancl and rtrancl **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
val [major] = goalw Trancl.thy [trancl_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   187
    "(a,b) : r^+ ==> (a,b) : r^*";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
by (resolve_tac [major RS compEpair] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
by (REPEAT (ares_tac [rtrancl_into_rtrancl] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
qed "trancl_into_rtrancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   191
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
(*r^+ contains r*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
val [prem] = goalw Trancl.thy [trancl_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   194
   "[| (a,b) : r |] ==> (a,b) : r^+";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
by (REPEAT (ares_tac [prem,compI,rtrancl_refl] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
qed "r_into_trancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   197
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
(*intro rule by definition: from rtrancl and r*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
val prems = goalw Trancl.thy [trancl_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   200
    "[| (a,b) : r^*;  (b,c) : r |]   ==>  (a,c) : r^+";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
by (REPEAT (resolve_tac ([compI]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   202
qed "rtrancl_into_trancl1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   203
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   204
(*intro rule from r and rtrancl*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   205
val prems = goal Trancl.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   206
    "[| (a,b) : r;  (b,c) : r^* |]   ==>  (a,c) : r^+";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   207
by (resolve_tac (prems RL [rtranclE]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   208
by (etac subst 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   209
by (resolve_tac (prems RL [r_into_trancl]) 1);
1122
20b708827030 renamed trans_rtrancl to rtrancl_trans and modified it by expanding trans.
nipkow
parents: 1121
diff changeset
   210
by (rtac (rtrancl_trans RS rtrancl_into_trancl1) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   211
by (REPEAT (ares_tac (prems@[r_into_rtrancl]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   212
qed "rtrancl_into_trancl2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   213
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   214
(*Nice induction rule for trancl*)
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   215
val major::prems = goal Trancl.thy
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   216
  "[| (a,b) : r^+;                                      \
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   217
\     !!y.  [| (a,y) : r |] ==> P(y);                   \
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   218
\     !!y z.[| (a,y) : r^+;  (y,z) : r;  P(y) |] ==> P(z)       \
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   219
\  |] ==> P(b)";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   220
by (rtac (rewrite_rule [trancl_def] major  RS  compEpair) 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   221
(*by induction on this formula*)
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   222
by (subgoal_tac "ALL z. (y,z) : r --> P(z)" 1);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   223
(*now solve first subgoal: this formula is sufficient*)
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   224
by (Fast_tac 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   225
by (etac rtrancl_induct 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   226
by (ALLGOALS (fast_tac (!claset addIs (rtrancl_into_trancl1::prems))));
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   227
qed "trancl_induct";
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   228
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   229
(*elimination of r^+ -- NOT an induction rule*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   230
val major::prems = goal Trancl.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   231
    "[| (a::'a,b) : r^+;  \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   232
\       (a,b) : r ==> P; \
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1301
diff changeset
   233
\       !!y.[| (a,y) : r^+;  (y,b) : r |] ==> P  \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   234
\    |] ==> P";
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   235
by (subgoal_tac "(a::'a,b) : r | (? y. (a,y) : r^+  &  (y,b) : r)" 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   236
by (REPEAT (eresolve_tac ([asm_rl,disjE,exE,conjE]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   237
by (rtac (rewrite_rule [trancl_def] major RS compEpair) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   238
by (etac rtranclE 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   239
by (Fast_tac 1);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   240
by (fast_tac (!claset addSIs [rtrancl_into_trancl1]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   241
qed "tranclE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   242
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   243
(*Transitivity of r^+.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   244
  Proved by unfolding since it uses transitivity of rtrancl. *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   245
goalw Trancl.thy [trancl_def] "trans(r^+)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   246
by (rtac transI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   247
by (REPEAT (etac compEpair 1));
1122
20b708827030 renamed trans_rtrancl to rtrancl_trans and modified it by expanding trans.
nipkow
parents: 1121
diff changeset
   248
by (rtac (rtrancl_into_rtrancl RS (rtrancl_trans RS compI)) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   249
by (REPEAT (assume_tac 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
qed "trans_trancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   251
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   252
bind_thm ("trancl_trans", trans_trancl RS transD);
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   253
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   254
val prems = goal Trancl.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   255
    "[| (a,b) : r;  (b,c) : r^+ |]   ==>  (a,c) : r^+";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   256
by (rtac (r_into_trancl RS (trans_trancl RS transD)) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   258
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
qed "trancl_into_trancl2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   260
1130
0df0df1685a8 Added trancl_cs
nipkow
parents: 1128
diff changeset
   261
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   262
val major::prems = goal Trancl.thy
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   263
    "[| (a,b) : r^*;  r <= A Times A |] ==> a=b | a:A";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   264
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
by (rtac (major RS rtrancl_induct) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   266
by (rtac (refl RS disjI1) 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   267
by (fast_tac (!claset addSEs [SigmaE2]) 1);
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   268
val lemma = result();
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   270
goalw Trancl.thy [trancl_def]
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   271
    "!!r. r <= A Times A ==> r^+ <= A Times A";
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   272
by (fast_tac (!claset addSDs [lemma]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   273
qed "trancl_subset_Sigma";
1130
0df0df1685a8 Added trancl_cs
nipkow
parents: 1128
diff changeset
   274
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1130
diff changeset
   275
(* Don't add r_into_rtrancl: it messes up the proofs in Lambda *)
1130
0df0df1685a8 Added trancl_cs
nipkow
parents: 1128
diff changeset
   276
val trancl_cs = rel_cs addIs [rtrancl_refl];
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1552
diff changeset
   277
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   278
AddIs [rtrancl_refl];