src/ZF/ex/Commutation.thy
author paulson
Mon, 04 Feb 2002 13:16:54 +0100
changeset 12867 5c900a821a7c
parent 11316 b4e71bd751e4
child 13248 ae66c22ed52e
permissions -rw-r--r--
New-style versions of these old examples
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
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    10
theory Commutation = Main:
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    11
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    12
constdefs
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    13
  square  :: "[i, i, i, i] => o"
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    14
   "square(r,s,t,u) ==
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    15
     (\<forall>a b. <a,b> \<in> r --> (\<forall>c. <a, c> \<in> s --> (\<exists>x. <b,x> \<in> t & <c,x> \<in> u)))"
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    16
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    17
  commute :: "[i, i] => o"
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    18
   "commute(r,s) == square(r,s,s,r)"
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    19
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    20
  diamond :: "i=>o"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    21
   "diamond(r)   == commute(r, r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    22
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    23
  strip :: "i=>o"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    24
   "strip(r) == commute(r^*, r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    25
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    26
  Church_Rosser :: "i => o"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    27
   "Church_Rosser(r) == (\<forall>x y. <x,y> \<in>  (r Un converse(r))^* -->
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    28
	 	 	 (\<exists>z. <x,z> \<in> r^* & <y,z> \<in> r^*))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    29
  confluent :: "i=>o"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    30
   "confluent(r) == diamond(r^*)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    31
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    32
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    33
lemma square_sym: "square(r,s,t,u) ==> square(s,r,u,t)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    34
by (unfold square_def, blast)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    35
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    36
lemma square_subset: "[| square(r,s,t,u); t \<subseteq> t' |] ==> square(r,s,t',u)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    37
by (unfold square_def, blast)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    38
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    39
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    40
lemma square_rtrancl [rule_format]: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    41
     "square(r,s,s,t) --> field(s)<=field(t) --> square(r^*,s,s,t^*)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    42
apply (unfold square_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    43
apply clarify
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    44
apply (erule rtrancl_induct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    45
apply (blast intro: rtrancl_refl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    46
apply (blast intro: rtrancl_into_rtrancl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    47
done
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    48
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    49
(* A special case of square_rtrancl_on *)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    50
lemma diamond_strip: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    51
 "diamond(r) ==> strip(r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    52
apply (unfold diamond_def commute_def strip_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    53
apply (rule square_rtrancl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    54
apply simp_all
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    55
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    56
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    57
(*** commute ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    58
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    59
lemma commute_sym: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    60
    "commute(r,s) ==> commute(s,r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    61
by (unfold commute_def, blast intro: square_sym)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    62
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    63
lemma commute_rtrancl [rule_format]: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    64
    "commute(r,s) ==> field(r)=field(s) --> commute(r^*,s^*)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    65
apply (unfold commute_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    66
apply clarify
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    67
apply (rule square_rtrancl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    68
apply (rule square_sym [THEN square_rtrancl, THEN square_sym]) 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    69
apply (simp_all add: rtrancl_field)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    70
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    71
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    72
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    73
lemma confluentD: "confluent(r) ==> diamond(r^*)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    74
by (simp add: confluent_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    75
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    76
lemma strip_confluent: "strip(r) ==> confluent(r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    77
apply (unfold strip_def confluent_def diamond_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    78
apply (drule commute_rtrancl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    79
apply (simp_all add: rtrancl_field)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    80
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    81
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    82
lemma commute_Un: "[| commute(r,t); commute(s,t) |] ==> commute(r Un s, t)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    83
by (unfold commute_def square_def, blast)
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
    84
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    85
lemma diamond_Un: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    86
     "[| diamond(r); diamond(s); commute(r, s) |] ==> diamond(r Un s)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    87
by (unfold diamond_def, blast intro: commute_Un commute_sym) 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    88
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    89
lemma diamond_confluent: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    90
    "diamond(r) ==> confluent(r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    91
apply (unfold diamond_def confluent_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    92
apply (erule commute_rtrancl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    93
apply simp
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    94
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    95
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    96
lemma confluent_Un: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    97
 "[| confluent(r); confluent(s); commute(r^*, s^*);  
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    98
     r \<subseteq> Sigma(A,B); s \<subseteq> Sigma(C,D) |] ==> confluent(r Un s)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
    99
apply (unfold confluent_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   100
apply (rule rtrancl_Un_rtrancl [THEN subst])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   101
apply auto
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   102
apply (blast dest: diamond_Un intro: diamond_confluent [THEN confluentD])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   103
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   104
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   105
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   106
lemma diamond_to_confluence: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   107
     "[| diamond(r); s \<subseteq> r; r<= s^* |] ==> confluent(s)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   108
apply (drule rtrancl_subset [symmetric])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   109
apply assumption
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   110
apply (simp_all add: confluent_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   111
apply (blast intro: diamond_confluent [THEN confluentD])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   112
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   113
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   114
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   115
(*** Church_Rosser ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   116
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   117
lemma Church_Rosser1: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   118
     "Church_Rosser(r) ==> confluent(r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   119
apply (unfold confluent_def Church_Rosser_def square_def 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   120
              commute_def diamond_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   121
apply auto
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   122
apply (drule converseI)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   123
apply (simp (no_asm_use) add: rtrancl_converse [symmetric])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   124
apply (drule_tac x = "b" in spec)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   125
apply (drule_tac x1 = "c" in spec [THEN mp])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   126
apply (rule_tac b = "a" in rtrancl_trans)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   127
apply (blast intro: rtrancl_mono [THEN subsetD])+
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   128
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   129
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   130
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   131
lemma Church_Rosser2: 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   132
     "confluent(r) ==> Church_Rosser(r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   133
apply (unfold confluent_def Church_Rosser_def square_def 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   134
              commute_def diamond_def)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   135
apply auto
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   136
apply (frule fieldI1)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   137
apply (simp add: rtrancl_field)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   138
apply (erule rtrancl_induct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   139
apply auto
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   140
apply (blast intro: rtrancl_refl)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   141
apply (blast del: rtrancl_refl intro: r_into_rtrancl rtrancl_trans)+
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   142
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   143
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   144
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   145
lemma Church_Rosser: "Church_Rosser(r) <-> confluent(r)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   146
by (blast intro: Church_Rosser1 Church_Rosser2)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11316
diff changeset
   147
11042
bb566dd3f927 commutation theory, ported by Sidi Ehmety
paulson
parents:
diff changeset
   148
end