src/ZF/ex/Commutation.ML
author wenzelm
Thu, 15 Feb 2001 17:18:54 +0100
changeset 11145 3e47692e3a3e
parent 11042 bb566dd3f927
child 11316 b4e71bd751e4
permissions -rw-r--r--
eliminate get_def;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Lambda/Commutation.thy
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     2
    ID:         $Id$
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     3
    Author:     Tobias Nipkow & Sidi Ould Ehmety
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     4
    Copyright   1995  TU Muenchen
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     5
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     6
Commutation theory for proving the Church Rosser theorem
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     7
	ported from Isabelle/HOL  by Sidi Ould Ehmety
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     8
*)
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
     9
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    10
Goalw [square_def] "square(r,s,t,u) ==> square(s,r,u,t)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    11
by (Blast_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    12
qed "square_sym";                
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    13
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    14
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    15
Goalw [square_def] "[| square(r,s,t,u); t <= t' |] ==> square(r,s,t',u)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    16
by (Blast_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    17
qed "square_subset"; 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    18
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    19
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    20
Goalw [square_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    21
 "field(s)<=field(t)==> square(r,s,s,t) --> square(r^*,s,s,t^*)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    22
by (Clarify_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    23
by (etac rtrancl_induct 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    24
by (blast_tac (claset()  addIs [rtrancl_refl]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    25
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    26
qed_spec_mp "square_rtrancl";                 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    27
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    28
(* A special case of square_rtrancl_on *)
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    29
Goalw [diamond_def, commute_def, strip_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    30
 "diamond(r) ==> strip(r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    31
by (resolve_tac [square_rtrancl] 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    32
by (ALLGOALS(Asm_simp_tac));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    33
qed "diamond_strip";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    34
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    35
(*** commute ***)
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    36
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    37
Goalw [commute_def] 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    38
    "commute(r,s) ==> commute(s,r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    39
by (blast_tac (claset() addIs [square_sym]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    40
qed "commute_sym";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    41
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    42
Goalw [commute_def] 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    43
"commute(r,s) ==> field(r)=field(s) --> commute(r^*,s^*)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    44
by (Clarify_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    45
by (rtac square_rtrancl 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    46
by (rtac square_sym  2);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    47
by (rtac square_rtrancl 2);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    48
by (rtac square_sym  3);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    49
by (ALLGOALS(asm_simp_tac 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    50
        (simpset() addsimps [rtrancl_field])));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    51
qed_spec_mp "commute_rtrancl";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    52
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    53
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    54
Goalw [strip_def,confluent_def, diamond_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    55
"strip(r) ==> confluent(r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    56
by (dtac commute_rtrancl 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    57
by (ALLGOALS(asm_full_simp_tac (simpset() 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    58
   addsimps [rtrancl_field])));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    59
qed "strip_confluent";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    60
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    61
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    62
Goalw [commute_def,square_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    63
  "[| commute(r,t); commute(s,t) |] ==> commute(r Un s, t)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    64
by (Blast_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    65
qed "commute_Un";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    66
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    67
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    68
Goalw [diamond_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    69
  "[| diamond(r); diamond(s); commute(r, s) |] \
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    70
\ ==> diamond(r Un s)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    71
by (REPEAT(ares_tac [commute_Un,commute_sym] 1));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    72
qed "diamond_Un";                                           
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    73
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    74
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    75
Goalw [diamond_def,confluent_def] 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    76
    "diamond(r) ==> confluent(r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    77
by (etac commute_rtrancl 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    78
by (Simp_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    79
qed "diamond_confluent";            
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    80
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    81
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    82
Goalw [confluent_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    83
 "[| confluent(r); confluent(s); commute(r^*, s^*); \
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    84
\           r<=Sigma(A,B); s<=Sigma(C,D) |] ==> confluent(r Un s)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    85
by (rtac (rtrancl_Un_rtrancl RS subst) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    86
by (blast_tac (claset() addDs [diamond_Un] 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    87
     addIs [rewrite_rule [confluent_def] diamond_confluent]) 3);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    88
by Auto_tac;
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    89
qed "confluent_Un";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    90
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    91
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    92
Goal
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    93
 "[| diamond(r); s<=r; r<= s^* |] ==> confluent(s)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    94
by (dresolve_tac [rtrancl_subset RS sym] 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    95
by (assume_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    96
by (ALLGOALS(asm_simp_tac (simpset() addsimps[confluent_def])));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    97
by (resolve_tac [rewrite_rule [confluent_def] diamond_confluent] 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    98
by (Asm_simp_tac 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    99
qed "diamond_to_confluence";               
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   100
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   101
(*** Church_Rosser ***)
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   102
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   103
Goalw [confluent_def, Church_Rosser_def, square_def,commute_def,diamond_def]
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   104
  "Church_Rosser(r) ==> confluent(r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   105
by Auto_tac;
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   106
by (dtac converseI 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   107
by (full_simp_tac (simpset() 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   108
                   addsimps [rtrancl_converse RS sym]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   109
by (dres_inst_tac [("x", "b")] spec 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   110
by (dres_inst_tac [("x1", "c")] (spec RS mp) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   111
by (res_inst_tac [("b", "a")] rtrancl_trans 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   112
by (REPEAT(blast_tac (claset() addIs [rtrancl_mono RS subsetD]) 1));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   113
qed "Church_Rosser1";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   114
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   115
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   116
Goalw [confluent_def, Church_Rosser_def, square_def,commute_def,diamond_def]  
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   117
"confluent(r) ==> Church_Rosser(r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   118
by Auto_tac;
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   119
by (forward_tac [fieldI1] 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   120
by (full_simp_tac (simpset() addsimps [rtrancl_field]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   121
by (etac rtrancl_induct 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   122
by (ALLGOALS(Clarify_tac));
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   123
by (blast_tac (claset() addIs [rtrancl_refl]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   124
by (blast_tac (claset() delrules [rtrancl_refl] 
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   125
                        addIs [r_into_rtrancl, rtrancl_trans]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   126
qed "Church_Rosser2";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   127
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   128
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   129
Goal "Church_Rosser(r) <-> confluent(r)";
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   130
by (blast_tac(claset() addIs [Church_Rosser1,Church_Rosser2]) 1);
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   131
qed "Church_Rosser";