src/HOL/Lambda/Commutation.ML
author nipkow
Wed, 11 Oct 1995 10:09:56 +0100
changeset 1278 7e6189fc833c
child 1302 ddfdcc9ce667
permissions -rw-r--r--
Commutation replaces Confluence
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1278
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Lambda/Commutation.thy
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     2
    ID:         $Id$
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     4
    Copyright   1995 TU Muenchen
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     5
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     6
Basic commutation lemmas.
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     7
*)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     8
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
     9
open Commutation;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    10
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    11
(* FIXME: move to Trancl *)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    12
(* FIXME: add rtrancl_idemp globally *)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    13
Addsimps [rtrancl_idemp];
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    14
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    15
goal Trancl.thy "!!R. [| R <= S; S <= R^* |] ==> S^* = R^*";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    16
bd rtrancl_mono 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    17
bd rtrancl_mono 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    18
by(Asm_full_simp_tac 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    19
by(fast_tac eq_cs 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    20
qed "rtrancl_subset";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    21
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    22
(* FIXME: move to Trancl *)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    23
goal Trancl.thy "!!R. p:R ==> p:R^*";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    24
by(res_inst_tac [("p","p")] PairE 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    25
by(fast_tac (HOL_cs addIs [r_into_rtrancl]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    26
qed "r_into_rtrancl1";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    27
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    28
(* FIXME: move to Trancl *)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    29
goal Trancl.thy "!!R. (R^* Un S^*)^* = (R Un S)^*";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    30
by(best_tac (set_cs addIs [rtrancl_subset,r_into_rtrancl1,
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    31
                           rtrancl_mono RS subsetD]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    32
qed "trancl_Un_trancl";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    33
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    34
(* FIXME: move to Trancl *)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    35
goal Commutation.thy "(R^=)^* = R^*";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    36
by(fast_tac (trancl_cs addIs [rtrancl_subset,r_into_rtrancl1]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    37
qed "rtrancl_reflcl";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    38
Addsimps [rtrancl_reflcl];
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    39
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    40
(*** square ***)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    41
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    42
goalw Commutation.thy [square_def] "!!R. square R S T U ==> square S R U T";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    43
by(fast_tac HOL_cs 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    44
qed "square_sym";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    45
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    46
goalw Commutation.thy [square_def]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    47
  "!!R. [| square R S T (R^=); S <= T |] ==> square (R^=) S T (R^=)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    48
by(fast_tac rel_cs 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    49
qed "square_reflcl";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    50
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    51
goalw Commutation.thy [square_def]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    52
  "!!R. square R S S T ==> square (R^*) S S (T^*)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    53
by(strip_tac 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    54
be rtrancl_induct 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    55
by(fast_tac trancl_cs 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    56
by(fast_tac (HOL_cs addSEs [rtrancl_into_rtrancl]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    57
qed "square_rtrancl";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    58
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    59
(* A big fast_tac runs out of store. Search space too large? *)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    60
goalw Commutation.thy [commute_def]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    61
 "!!R. square R S (S^*) (R^=) ==> commute (R^*) (S^*)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    62
bd square_reflcl 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    63
br subsetI 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    64
be r_into_rtrancl1 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    65
bd square_sym 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    66
bd square_rtrancl 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    67
by(Asm_full_simp_tac 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    68
bd square_sym 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    69
bd square_rtrancl 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    70
by(Asm_full_simp_tac 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    71
qed "square_rtrancl_reflcl_commute";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    72
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    73
(*** commute ***)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    74
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    75
goalw Commutation.thy [commute_def] "!!R. commute R S ==> commute S R";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    76
by(fast_tac (HOL_cs addIs [square_sym]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    77
qed "commute_sym";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    78
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    79
goalw Commutation.thy [commute_def] "!!R. commute R S ==> commute (R^*) (S^*)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    80
by(fast_tac (HOL_cs addIs [square_rtrancl,square_sym]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    81
qed "commute_rtrancl";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    82
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    83
goalw Commutation.thy [commute_def,square_def]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    84
  "!!R. [| commute R T; commute S T |] ==> commute (R Un S) T";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    85
by(fast_tac set_cs 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    86
qed "commute_Un";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    87
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    88
(*** diamond, confluence and union ***)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    89
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    90
goalw Commutation.thy [diamond_def]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    91
  "!!R. [| diamond R; diamond S; commute R S |] ==> diamond (R Un S)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    92
by(REPEAT(ares_tac [commute_Un,commute_sym] 1));
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    93
qed "diamond_Un";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    94
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    95
goalw Commutation.thy [diamond_def] "!!R. diamond R ==> confluent (R)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    96
be commute_rtrancl 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    97
qed "diamond_confluent";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    98
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
    99
goal Commutation.thy
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   100
 "!!R. [| confluent R; confluent S; commute (R^*) (S^*) |] \
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   101
\      ==> confluent(R Un S)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   102
br(trancl_Un_trancl RS subst) 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   103
by(fast_tac (HOL_cs addDs [diamond_Un] addIs [diamond_confluent]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   104
qed "confluent_Un";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   105
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   106
goal Commutation.thy
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   107
  "!!R.[| diamond(R); T <= R; R <= T^* |] ==> confluent(T)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   108
by(fast_tac (HOL_cs addIs [diamond_confluent]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   109
                    addDs [rtrancl_subset RS sym] addss HOL_ss) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   110
qed "diamond_to_confluence";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   111
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   112
(*** Church_Rosser ***)
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   113
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   114
goalw Commutation.thy [square_def,commute_def,diamond_def,Church_Rosser_def]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   115
  "Church_Rosser(R) = confluent(R)";
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   116
br iffI 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   117
 by(fast_tac (HOL_cs addIs
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   118
      [Un_upper2 RS rtrancl_mono RS subsetD RS rtrancl_trans,
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   119
       rtrancl_converseI, converseI, Un_upper1 RS rtrancl_mono RS subsetD])1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   120
by(safe_tac HOL_cs);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   121
be rtrancl_induct 1;
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   122
 by(fast_tac trancl_cs 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   123
 by(slow_tac (rel_cs addIs [r_into_rtrancl]
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   124
                     addEs [rtrancl_trans,r_into_rtrancl RS rtrancl_trans]) 1);
7e6189fc833c Commutation replaces Confluence
nipkow
parents:
diff changeset
   125
qed "Church_Rosser_confluent";