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