src/ZF/Resid/Residuals.thy
author paulson
Sat, 22 Dec 2001 19:42:35 +0100
changeset 12593 cd35fe5947d4
parent 11319 8b84ee2cc79c
child 12610 8b9845807f77
permissions -rw-r--r--
Resid converted to Isar/ZF
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     1
(*  Title:      Residuals.thy
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     2
    ID:         $Id$
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     3
    Author:     Ole Rasmussen
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     4
    Copyright   1995  University of Cambridge
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     5
    Logic Image: ZF
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     6
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     7
*)
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     8
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
     9
theory Residuals = Substitution:
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    10
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    11
consts
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    12
  Sres          :: "i"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    13
  residuals     :: "[i,i,i]=>i"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    14
  "|>"          :: "[i,i]=>i"     (infixl 70)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    15
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    16
translations
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    17
  "residuals(u,v,w)"  == "<u,v,w> \<in> Sres"
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    18
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    19
inductive
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    20
  domains       "Sres" <= "redexes*redexes*redexes"
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    21
  intros
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    22
    Res_Var:    "n \<in> nat ==> residuals(Var(n),Var(n),Var(n))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    23
    Res_Fun:    "[|residuals(u,v,w)|]==>   
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
    24
                     residuals(Fun(u),Fun(v),Fun(w))"
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    25
    Res_App:    "[|residuals(u1,v1,w1);   
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    26
                   residuals(u2,v2,w2); b \<in> bool|]==>   
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
    27
                 residuals(App(b,u1,u2),App(0,v1,v2),App(b,w1,w2))"
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    28
    Res_redex:  "[|residuals(u1,v1,w1);   
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    29
                   residuals(u2,v2,w2); b \<in> bool|]==>   
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
    30
                 residuals(App(b,Fun(u1),u2),App(1,Fun(v1),v2),w2/w1)"
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    31
  type_intros    subst_type nat_typechecks redexes.intros bool_typechecks
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    32
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    33
defs
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    34
  res_func_def:  "u |> v == THE w. residuals(u,v,w)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    35
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    36
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    37
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    38
(*       Setting up rule lists                                               *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    39
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    40
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    41
declare Sres.intros [intro]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    42
declare Sreg.intros [intro]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    43
declare subst_type [intro]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    44
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    45
inductive_cases [elim!]: "residuals(Var(n),Var(n),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    46
inductive_cases [elim!]: "residuals(Fun(t),Fun(u),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    47
inductive_cases [elim!]: "residuals(App(b, u1, u2), App(0, v1, v2),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    48
inductive_cases [elim!]: "residuals(App(b, u1, u2), App(1, Fun(v1), v2),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    49
inductive_cases [elim!]: "residuals(Var(n),u,v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    50
inductive_cases [elim!]: "residuals(Fun(t),u,v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    51
inductive_cases [elim!]: "residuals(App(b, u1, u2), w,v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    52
inductive_cases [elim!]: "residuals(u,Var(n),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    53
inductive_cases [elim!]: "residuals(u,Fun(t),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    54
inductive_cases [elim!]: "residuals(w,App(b, u1, u2),v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    55
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    56
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    57
inductive_cases [elim!]: "Var(n) <== u"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    58
inductive_cases [elim!]: "Fun(n) <== u"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    59
inductive_cases [elim!]: "u <== Fun(n)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    60
inductive_cases [elim!]: "App(1,Fun(t),a) <== u"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    61
inductive_cases [elim!]: "App(0,t,a) <== u"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    62
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    63
inductive_cases [elim!]: "Fun(t):redexes"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    64
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    65
declare Sres.intros [simp]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    66
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    67
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    68
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    69
(*       residuals is a  partial function                                    *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    70
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    71
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    72
lemma residuals_function [rule_format]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    73
     "residuals(u,v,w) ==> \<forall>w1. residuals(u,v,w1) --> w1 = w"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    74
by (erule Sres.induct, force+)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    75
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    76
lemma residuals_intro [rule_format]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    77
     "u~v ==> regular(v) --> (\<exists>w. residuals(u,v,w))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    78
by (erule Scomp.induct, force+)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    79
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    80
lemma comp_resfuncD:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    81
     "[| u~v;  regular(v) |] ==> residuals(u, v, THE w. residuals(u, v, w))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    82
apply (frule residuals_intro, assumption)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    83
apply clarify
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    84
apply (subst the_equality)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    85
apply (blast intro: residuals_function)+
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    86
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    87
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    88
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    89
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    90
(*               Residual function                                           *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    91
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    92
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    93
lemma res_Var [simp]: "n \<in> nat ==> Var(n) |> Var(n) = Var(n)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    94
by (unfold res_func_def, blast)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    95
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    96
lemma res_Fun [simp]: 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    97
    "[|s~t; regular(t)|]==> Fun(s) |> Fun(t) = Fun(s |> t)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    98
apply (unfold res_func_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    99
apply (blast intro: comp_resfuncD residuals_function) 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   100
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   101
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   102
lemma res_App [simp]: 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   103
    "[|s~u; regular(u); t~v; regular(v); b \<in> bool|]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   104
     ==> App(b,s,t) |> App(0,u,v) = App(b, s |> u, t |> v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   105
apply (unfold res_func_def) 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   106
apply (blast dest!: comp_resfuncD intro: residuals_function)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   107
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   108
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   109
lemma res_redex [simp]: 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   110
    "[|s~u; regular(u); t~v; regular(v); b \<in> bool|]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   111
     ==> App(b,Fun(s),t) |> App(1,Fun(u),v) = (t |> v)/ (s |> u)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   112
apply (unfold res_func_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   113
apply (blast elim!: redexes.free_elims dest!: comp_resfuncD 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   114
             intro: residuals_function)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   115
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   116
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   117
lemma resfunc_type [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   118
     "[|s~t; regular(t)|]==> regular(t) --> s |> t \<in> redexes"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   119
apply (erule Scomp.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   120
apply auto
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   121
apply (drule_tac psi = "Fun (?u) |> ?v \<in> redexes" in asm_rl)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   122
apply auto
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   123
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   124
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   125
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   126
(*     Commutation theorem                                                   *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   127
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   128
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   129
lemma sub_comp [simp]: "u<==v ==> u~v"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   130
by (erule Ssub.induct, simp_all)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   131
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   132
lemma sub_preserve_reg [rule_format, simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   133
     "u<==v  ==> regular(v) --> regular(u)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   134
by (erule Ssub.induct, auto)
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
   135
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   136
lemma residuals_lift_rec: "[|u~v; k \<in> nat|]==> regular(v)--> (\<forall>n \<in> nat.   
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   137
         lift_rec(u,n) |> lift_rec(v,n) = lift_rec(u |> v,n))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   138
apply (erule Scomp.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   139
apply safe
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   140
apply (simp_all add: lift_rec_Var subst_Var lift_subst)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   141
apply (rotate_tac -2)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   142
apply simp
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   143
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   144
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   145
lemma residuals_subst_rec:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   146
     "u1~u2 ==>  \<forall>v1 v2. v1~v2 --> regular(v2) --> regular(u2) --> 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   147
                  (\<forall>n \<in> nat. subst_rec(v1,u1,n) |> subst_rec(v2,u2,n) =  
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   148
                    subst_rec(v1 |> v2, u1 |> u2,n))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   149
apply (erule Scomp.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   150
apply safe
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   151
apply (simp_all add: lift_rec_Var subst_Var residuals_lift_rec)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   152
apply (drule_tac psi = "\<forall>x.?P (x) " in asm_rl)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   153
apply (simp add: substitution)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   154
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   155
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   156
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   157
lemma commutation [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   158
     "[|u1~u2; v1~v2; regular(u2); regular(v2)|]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   159
      ==> (v1/u1) |> (v2/u2) = (v1 |> v2)/(u1 |> u2)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   160
by (simp add: residuals_subst_rec)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   161
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   162
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   163
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   164
(*     Residuals are comp and regular                                        *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   165
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   166
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   167
lemma residuals_preserve_comp [rule_format, simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   168
     "u~v ==> \<forall>w. u~w --> v~w --> regular(w) --> (u|>w) ~ (v|>w)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   169
by (erule Scomp.induct, force+)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   170
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   171
lemma residuals_preserve_reg [rule_format, simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   172
     "u~v ==> regular(u) --> regular(v) --> regular(u|>v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   173
apply (erule Scomp.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   174
apply auto
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   175
apply (drule_tac psi = "regular (Fun (?u) |> ?v)" in asm_rl, force)+
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   176
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   177
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   178
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   179
(*     Preservation lemma                                                    *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   180
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   181
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   182
lemma union_preserve_comp: "u~v ==> v ~ (u un v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   183
by (erule Scomp.induct, simp_all)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   184
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   185
lemma preservation [rule_format]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   186
     "u ~ v ==> regular(v) --> u|>v = (u un v)|>v"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   187
apply (erule Scomp.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   188
apply safe
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   189
apply (drule_tac [3] psi = "Fun (?u) |> ?v = ?w" in asm_rl)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   190
apply (auto simp add: union_preserve_comp comp_sym_iff)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   191
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   192
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   193
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   194
(**** And now the Cube ***)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   195
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   196
declare sub_comp [THEN comp_sym, simp]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   197
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   198
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   199
(*         Prism theorem                                                     *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   200
(*         =============                                                     *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   201
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   202
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   203
(* Having more assumptions than needed -- removed below  *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   204
lemma prism_l [rule_format]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   205
     "v<==u ==>  
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   206
       regular(u) --> (\<forall>w. w~v --> w~u -->   
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   207
                            w |> u = (w|>v) |> (u|>v))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   208
apply (erule Ssub.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   209
apply force+
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   210
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   211
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   212
lemma prism:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   213
     "[|v <== u; regular(u); w~v|] ==> w |> u = (w|>v) |> (u|>v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   214
apply (rule prism_l)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   215
apply (rule_tac [4] comp_trans)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   216
apply auto
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   217
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   218
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   219
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   220
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   221
(*    Levy's Cube Lemma                                                      *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   222
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   223
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   224
lemma cube: "[|u~v; regular(v); regular(u); w~u|]==>   
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   225
           (w|>u) |> (v|>u) = (w|>v) |> (u|>v)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   226
apply (subst preservation , assumption , assumption)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   227
apply (subst preservation , erule comp_sym , assumption)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   228
apply (subst prism [symmetric])
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   229
apply (simp add: union_r comp_sym_iff)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   230
apply (simp add: union_preserve_regular comp_sym_iff)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   231
apply (erule comp_trans)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   232
apply assumption
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   233
apply (simp add: prism [symmetric] union_l union_preserve_regular 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   234
                 comp_sym_iff union_sym)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   235
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   236
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   237
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   238
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   239
(*           paving theorem                                                  *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   240
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   241
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   242
lemma paving: "[|w~u; w~v; regular(u); regular(v)|]==>  
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   243
           \<exists>uv vu. (w|>u) |> vu = (w|>v) |> uv & (w|>u)~vu & 
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   244
             regular(vu) & (w|>v)~uv & regular(uv) "
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   245
apply (subgoal_tac "u~v")
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   246
apply (safe intro!: exI)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   247
apply (rule cube)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   248
apply (simp_all add: comp_sym_iff)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   249
apply (blast intro: residuals_preserve_comp comp_trans comp_sym)+
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   250
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   251
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   252
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
   253
end
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
   254