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