author | paulson |
Mon, 29 Sep 1997 11:51:52 +0200 | |
changeset 3734 | 33f355f56f82 |
parent 2469 | b50b8c0eec01 |
child 3840 | e0baea4d485a |
permissions | -rw-r--r-- |
1461 | 1 |
(* Title: Residuals.ML |
1048 | 2 |
ID: $Id$ |
1461 | 3 |
Author: Ole Rasmussen |
1048 | 4 |
Copyright 1995 University of Cambridge |
5 |
Logic Image: ZF |
|
6 |
*) |
|
7 |
||
8 |
open Residuals; |
|
9 |
||
10 |
(* ------------------------------------------------------------------------- *) |
|
11 |
(* Setting up rule lists *) |
|
12 |
(* ------------------------------------------------------------------------- *) |
|
13 |
||
2469 | 14 |
AddIs (Sres.intrs@redexes.intrs@Sreg.intrs@ |
15 |
[subst_type]@nat_typechecks); |
|
16 |
AddSEs (redexes.free_SEs @ |
|
17 |
(map (Sres.mk_cases redexes.con_defs) |
|
18 |
["residuals(Var(n),Var(n),v)", |
|
19 |
"residuals(Fun(t),Fun(u),v)", |
|
20 |
"residuals(App(b, u1, u2), App(0, v1, v2),v)", |
|
21 |
"residuals(App(b, u1, u2), App(1, Fun(v1), v2),v)", |
|
22 |
"residuals(Var(n),u,v)", |
|
23 |
"residuals(Fun(t),u,v)", |
|
24 |
"residuals(App(b, u1, u2), w,v)", |
|
25 |
"residuals(u,Var(n),v)", |
|
26 |
"residuals(u,Fun(t),v)", |
|
27 |
"residuals(w,App(b, u1, u2),v)"]) @ |
|
28 |
(map (Ssub.mk_cases redexes.con_defs) |
|
29 |
["Var(n) <== u", |
|
30 |
"Fun(n) <== u", |
|
31 |
"u <== Fun(n)", |
|
32 |
"App(1,Fun(t),a) <== u", |
|
33 |
"App(0,t,a) <== u"]) @ |
|
34 |
[redexes.mk_cases redexes.con_defs "Fun(t):redexes"]); |
|
1048 | 35 |
|
2469 | 36 |
Addsimps Sres.intrs; |
1048 | 37 |
val resD1 =Sres.dom_subset RS subsetD RS SigmaD1; |
38 |
val resD2 =Sres.dom_subset RS subsetD RS SigmaD2 RS SigmaD1; |
|
39 |
val resD3 =Sres.dom_subset RS subsetD RS SigmaD2 RS SigmaD2; |
|
40 |
||
41 |
||
42 |
(* ------------------------------------------------------------------------- *) |
|
43 |
(* residuals is a partial function *) |
|
44 |
(* ------------------------------------------------------------------------- *) |
|
45 |
||
46 |
goal Residuals.thy |
|
47 |
"!!u.residuals(u,v,w) ==> ALL w1.residuals(u,v,w1) --> w1 = w"; |
|
1732 | 48 |
by (etac Sres.induct 1); |
2469 | 49 |
by (ALLGOALS Fast_tac); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
50 |
qed_spec_mp "residuals_function"; |
1048 | 51 |
|
52 |
goal Residuals.thy |
|
53 |
"!!u.u~v ==> regular(v) --> (EX w.residuals(u,v,w))"; |
|
1732 | 54 |
by (etac Scomp.induct 1); |
2469 | 55 |
by (ALLGOALS Fast_tac); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
56 |
qed "residuals_intro"; |
1048 | 57 |
|
58 |
val prems = goal Residuals.thy |
|
59 |
"[|u~v; residuals(u,v,THE w. residuals(u, v, w))==> R; \ |
|
60 |
\ regular(v)|] ==> R"; |
|
61 |
by (cut_facts_tac prems 1); |
|
62 |
by (resolve_tac prems 1); |
|
63 |
by (resolve_tac [residuals_intro RS mp RS exE] 1); |
|
64 |
by (resolve_tac [the_equality RS ssubst] 3); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
65 |
by (ALLGOALS (fast_tac (!claset addIs [residuals_function]))); |
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
66 |
qed "comp_resfuncE"; |
1048 | 67 |
|
68 |
||
69 |
(* ------------------------------------------------------------------------- *) |
|
70 |
(* Residual function *) |
|
71 |
(* ------------------------------------------------------------------------- *) |
|
72 |
||
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
73 |
val resfunc_cs = (!claset addIs [the_equality,residuals_function] |
2469 | 74 |
addSEs [comp_resfuncE]); |
1048 | 75 |
|
76 |
goalw Residuals.thy [res_func_def] |
|
77 |
"!!n.n:nat ==> Var(n) |> Var(n) = Var(n)"; |
|
78 |
by (fast_tac resfunc_cs 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
79 |
qed "res_Var"; |
1048 | 80 |
|
81 |
goalw Residuals.thy [res_func_def] |
|
82 |
"!!n.[|s~t; regular(t)|]==> Fun(s) |> Fun(t) = Fun(s |> t)"; |
|
83 |
by (fast_tac resfunc_cs 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
84 |
qed "res_Fun"; |
1048 | 85 |
|
86 |
goalw Residuals.thy [res_func_def] |
|
87 |
"!!n.[|s~u; regular(u); t~v; regular(v); b:bool|]==> \ |
|
88 |
\ App(b,s,t) |> App(0,u,v) = App(b, s |> u, t |> v)"; |
|
89 |
by (fast_tac resfunc_cs 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
90 |
qed "res_App"; |
1048 | 91 |
|
92 |
goalw Residuals.thy [res_func_def] |
|
93 |
"!!n.[|s~u; regular(u); t~v; regular(v); b:bool|]==> \ |
|
94 |
\ App(b,Fun(s),t) |> App(1,Fun(u),v) = (t |> v)/ (s |> u)"; |
|
95 |
by (fast_tac resfunc_cs 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
96 |
qed "res_redex"; |
1048 | 97 |
|
98 |
goal Residuals.thy |
|
99 |
"!!n.[|s~t; regular(t)|]==> regular(t) --> s |> t:redexes"; |
|
1732 | 100 |
by (etac Scomp.induct 1); |
1048 | 101 |
by (ALLGOALS (asm_full_simp_tac |
2469 | 102 |
(!simpset addsimps [res_Var,res_Fun,res_App,res_redex] |
103 |
setloop (SELECT_GOAL (safe_tac (!claset)))))); |
|
1048 | 104 |
by (dres_inst_tac [("psi", "Fun(?u) |> ?v : redexes")] asm_rl 1); |
105 |
by (asm_full_simp_tac |
|
2469 | 106 |
(!simpset addsimps [res_Fun] |
107 |
setloop (SELECT_GOAL (safe_tac (!claset)))) 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
108 |
qed "resfunc_type"; |
1048 | 109 |
|
2469 | 110 |
Addsimps ([res_Var, res_Fun, res_App, res_redex, lift_rec_preserve_comp, |
111 |
lift_rec_preserve_reg, subst_rec_preserve_comp, resfunc_type, |
|
112 |
subst_rec_preserve_reg] @ |
|
113 |
redexes.free_iffs); |
|
1048 | 114 |
|
2469 | 115 |
val res1L_ss = !simpset setloop (SELECT_GOAL (safe_tac (!claset))); |
1048 | 116 |
|
117 |
(* ------------------------------------------------------------------------- *) |
|
118 |
(* Commutation theorem *) |
|
119 |
(* ------------------------------------------------------------------------- *) |
|
120 |
||
121 |
goal Residuals.thy |
|
122 |
"!!u.u<==v ==> u~v"; |
|
1732 | 123 |
by (etac Ssub.induct 1); |
2469 | 124 |
by (ALLGOALS Asm_simp_tac); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
125 |
qed "sub_comp"; |
1048 | 126 |
|
127 |
goal Residuals.thy |
|
128 |
"!!u.u<==v ==> regular(v) --> regular(u)"; |
|
1732 | 129 |
by (etac Ssub.induct 1); |
1048 | 130 |
by (ALLGOALS (asm_simp_tac res1L_ss)); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
131 |
qed "sub_preserve_reg"; |
1048 | 132 |
|
133 |
goal Residuals.thy |
|
134 |
"!!u.[|u~v; k:nat|]==> regular(v)--> (ALL n:nat. \ |
|
135 |
\ lift_rec(u,n) |> lift_rec(v,n) = lift_rec(u |> v,n))"; |
|
1732 | 136 |
by (etac Scomp.induct 1); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
137 |
by Safe_tac; |
2469 | 138 |
by (ALLGOALS (asm_full_simp_tac ((addsplit (!simpset)) addsimps [lift_subst]))); |
1048 | 139 |
by (dres_inst_tac [("psi", "ALL x:nat.Fun(?u(x)) |> ?v(x) = ?w(x)")] asm_rl 1); |
2469 | 140 |
by (Asm_full_simp_tac 1); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
141 |
qed "residuals_lift_rec"; |
1048 | 142 |
|
143 |
goal Residuals.thy |
|
144 |
"!!u.u1~u2 ==> ALL v1 v2.v1~v2 --> regular(v2) --> regular(u2) -->\ |
|
145 |
\ (ALL n:nat.subst_rec(v1,u1,n) |> subst_rec(v2,u2,n) = \ |
|
146 |
\ subst_rec(v1 |> v2, u1 |> u2,n))"; |
|
1732 | 147 |
by (etac Scomp.induct 1); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
148 |
by Safe_tac; |
1048 | 149 |
by (ALLGOALS |
2469 | 150 |
(asm_full_simp_tac ((addsplit (!simpset)) addsimps ([residuals_lift_rec])))); |
1048 | 151 |
by (dres_inst_tac [("psi", "ALL x.?P(x)")] asm_rl 1); |
2469 | 152 |
by (asm_full_simp_tac (!simpset addsimps ([substitution])) 1); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
153 |
qed "residuals_subst_rec"; |
1048 | 154 |
|
155 |
||
156 |
goal Residuals.thy |
|
157 |
"!!u.[|u1~u2; v1~v2; regular(u2); regular(v2)|]==>\ |
|
158 |
\ (v1/u1) |> (v2/u2) = (v1 |> v2)/(u1 |> u2)"; |
|
2469 | 159 |
by (asm_simp_tac (!simpset addsimps ([residuals_subst_rec])) 1); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
160 |
qed "commutation"; |
1048 | 161 |
|
162 |
(* ------------------------------------------------------------------------- *) |
|
163 |
(* Residuals are comp and regular *) |
|
164 |
(* ------------------------------------------------------------------------- *) |
|
165 |
||
166 |
goal Residuals.thy |
|
167 |
"!!u.u~v ==> ALL w. u~w --> v~w --> regular(w) --> (u|>w) ~ (v|>w)"; |
|
1732 | 168 |
by (etac Scomp.induct 1); |
2469 | 169 |
by (ALLGOALS (asm_simp_tac res1L_ss)); |
1048 | 170 |
by (dresolve_tac [spec RS mp RS mp RS mp] 1 |
171 |
THEN resolve_tac Scomp.intrs 1 THEN resolve_tac Scomp.intrs 2 |
|
172 |
THEN resolve_tac Sreg.intrs 3); |
|
173 |
by (REPEAT(assume_tac 1)); |
|
174 |
by (asm_full_simp_tac res1L_ss 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
175 |
qed_spec_mp "residuals_preserve_comp"; |
1048 | 176 |
|
177 |
||
178 |
goal Residuals.thy |
|
179 |
"!!u.u~v ==> regular(u) --> regular(v) --> regular(u|>v)"; |
|
1732 | 180 |
by (etac Scomp.induct 1); |
2469 | 181 |
by (safe_tac (!claset)); |
1048 | 182 |
by (TRYALL (dres_inst_tac [("psi", "regular(Fun(?u) |> ?v)")] asm_rl)); |
183 |
by (ALLGOALS (asm_full_simp_tac res1L_ss)); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
184 |
qed "residuals_preserve_reg"; |
1048 | 185 |
|
186 |
(* ------------------------------------------------------------------------- *) |
|
187 |
(* Preservation lemma *) |
|
188 |
(* ------------------------------------------------------------------------- *) |
|
189 |
||
190 |
goal Residuals.thy |
|
191 |
"!!u.u~v ==> v ~ (u un v)"; |
|
1732 | 192 |
by (etac Scomp.induct 1); |
2469 | 193 |
by (ALLGOALS Asm_full_simp_tac); |
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
194 |
qed "union_preserve_comp"; |
1048 | 195 |
|
196 |
goal Residuals.thy |
|
197 |
"!!u.u ~ v ==> regular(v) --> u|>v = (u un v)|>v"; |
|
1732 | 198 |
by (etac Scomp.induct 1); |
2469 | 199 |
by (safe_tac (!claset)); |
1048 | 200 |
by (dres_inst_tac [("psi", "Fun(?u) |> ?v = ?w")] asm_rl 3); |
201 |
by (ALLGOALS (asm_full_simp_tac (res1L_ss addsimps |
|
1461 | 202 |
[union_preserve_comp,comp_sym_iff]))); |
2469 | 203 |
by (asm_full_simp_tac (!simpset addsimps |
1461 | 204 |
[union_preserve_comp RS comp_sym, |
205 |
comp_sym RS union_preserve_comp RS comp_sym]) 1); |
|
3734
33f355f56f82
Much tidying including "qed" instead of result(), and even qed_spec_mp,
paulson
parents:
2469
diff
changeset
|
206 |
qed_spec_mp "preservation"; |