author | nipkow |
Tue, 09 Jan 2001 15:36:30 +0100 | |
changeset 10835 | f4745d77e620 |
parent 10230 | 5eb935d6cc69 |
child 11531 | d038246a62f2 |
permissions | -rw-r--r-- |
2276 | 1 |
(* Title: HOLCF/domain/theorems.ML |
2445
51993fea433f
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents:
2276
diff
changeset
|
2 |
ID: $Id$ |
2276 | 3 |
Author : David von Oheimb |
4 |
Copyright 1995, 1996 TU Muenchen |
|
2445
51993fea433f
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents:
2276
diff
changeset
|
5 |
|
51993fea433f
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents:
2276
diff
changeset
|
6 |
proof generator for domain section |
1274 | 7 |
*) |
8 |
||
2446
c2a9bf6c0948
The previous log message was wrong. The correct one is:
oheimb
parents:
2445
diff
changeset
|
9 |
|
1274 | 10 |
structure Domain_Theorems = struct |
11 |
||
12 |
local |
|
13 |
||
14 |
open Domain_Library; |
|
15 |
infixr 0 ===>;infixr 0 ==>;infix 0 == ; |
|
16 |
infix 1 ===; infix 1 ~= ; infix 1 <<; infix 1 ~<<; |
|
17 |
infix 9 ` ; infix 9 `% ; infix 9 `%%; infixr 9 oo; |
|
18 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
19 |
(* ----- general proof facilities ------------------------------------------- *) |
1274 | 20 |
|
4252 | 21 |
fun inferT sg pre_tm = #1 (Sign.infer_types sg (K None) (K None) [] true |
2033 | 22 |
([pre_tm],propT)); |
1274 | 23 |
|
24 |
fun pg'' thy defs t = let val sg = sign_of thy; |
|
2033 | 25 |
val ct = Thm.cterm_of sg (inferT sg t); |
26 |
in prove_goalw_cterm defs ct end; |
|
1274 | 27 |
fun pg' thy defs t tacsf=pg'' thy defs t (fn [] => tacsf |
2033 | 28 |
| prems=> (cut_facts_tac prems 1)::tacsf); |
1274 | 29 |
|
1674 | 30 |
local val trueI2 = prove_goal HOL.thy"f~=x ==> True"(fn _ => [rtac TrueI 1]) in |
1274 | 31 |
val kill_neq_tac = dtac trueI2 end; |
2033 | 32 |
fun case_UU_tac rews i v = case_tac (v^"=UU") i THEN |
33 |
asm_simp_tac (HOLCF_ss addsimps rews) i; |
|
1274 | 34 |
|
35 |
val chain_tac = REPEAT_DETERM o resolve_tac |
|
5291 | 36 |
[chain_iterate, ch2ch_Rep_CFunR, ch2ch_Rep_CFunL]; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
37 |
|
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
38 |
(* ----- general proofs ----------------------------------------------------- *) |
1274 | 39 |
|
1644 | 40 |
val all2E = prove_goal HOL.thy "[| !x y . P x y; P x y ==> R |] ==> R" |
41 |
(fn prems =>[ |
|
2033 | 42 |
resolve_tac prems 1, |
43 |
cut_facts_tac prems 1, |
|
44 |
fast_tac HOL_cs 1]); |
|
1274 | 45 |
|
10230 | 46 |
val dist_eqI = prove_goal Porder.thy "!!x::'a::po. ~ x << y ==> x ~= y" |
47 |
(fn prems => [ |
|
48 |
(blast_tac (claset() addDs [antisym_less_inverse]) 1)]); |
|
4755 | 49 |
(* |
50 |
infixr 0 y; |
|
51 |
val b = 0; |
|
52 |
fun _ y t = by t; |
|
53 |
fun g defs t = let val sg = sign_of thy; |
|
54 |
val ct = Thm.cterm_of sg (inferT sg t); |
|
55 |
in goalw_cterm defs ct end; |
|
56 |
*) |
|
1274 | 57 |
|
58 |
in |
|
59 |
||
4043 | 60 |
fun theorems (((dname,_),cons) : eq, eqs : eq list) thy = |
1274 | 61 |
let |
62 |
||
4030 | 63 |
val dummy = writeln ("Proving isomorphism properties of domain "^dname^" ..."); |
1274 | 64 |
val pg = pg' thy; |
65 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
66 |
|
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
67 |
(* ----- getting the axioms and definitions --------------------------------- *) |
1274 | 68 |
|
7906 | 69 |
local fun ga s dn = get_thm thy (dn^"."^s) in |
4043 | 70 |
val ax_abs_iso = ga "abs_iso" dname; |
71 |
val ax_rep_iso = ga "rep_iso" dname; |
|
72 |
val ax_when_def = ga "when_def" dname; |
|
73 |
val axs_con_def = map (fn (con,_) => ga (extern_name con^"_def") dname) cons; |
|
74 |
val axs_dis_def = map (fn (con,_) => ga ( dis_name con^"_def") dname) cons; |
|
1274 | 75 |
val axs_sel_def = flat(map (fn (_,args) => |
4043 | 76 |
map (fn arg => ga (sel_of arg ^"_def") dname) args) |
77 |
cons); |
|
78 |
val ax_copy_def = ga "copy_def" dname; |
|
1274 | 79 |
end; (* local *) |
80 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
81 |
(* ----- theorems concerning the isomorphism -------------------------------- *) |
1274 | 82 |
|
83 |
val dc_abs = %%(dname^"_abs"); |
|
84 |
val dc_rep = %%(dname^"_rep"); |
|
85 |
val dc_copy = %%(dname^"_copy"); |
|
86 |
val x_name = "x"; |
|
87 |
||
88 |
val (rep_strict, abs_strict) = let |
|
2033 | 89 |
val r = ax_rep_iso RS (ax_abs_iso RS (allI RSN(2,allI RS iso_strict))) |
90 |
in (r RS conjunct1, r RS conjunct2) end; |
|
1274 | 91 |
val abs_defin' = pg [] ((dc_abs`%x_name === UU) ==> (%x_name === UU)) [ |
2033 | 92 |
res_inst_tac [("t",x_name)] (ax_abs_iso RS subst) 1, |
93 |
etac ssubst 1, rtac rep_strict 1]; |
|
1274 | 94 |
val rep_defin' = pg [] ((dc_rep`%x_name === UU) ==> (%x_name === UU)) [ |
2033 | 95 |
res_inst_tac [("t",x_name)] (ax_rep_iso RS subst) 1, |
96 |
etac ssubst 1, rtac abs_strict 1]; |
|
1274 | 97 |
val iso_rews = [ax_abs_iso,ax_rep_iso,abs_strict,rep_strict]; |
98 |
||
99 |
local |
|
100 |
val iso_swap = pg [] (dc_rep`%"x" === %"y" ==> %"x" === dc_abs`%"y") [ |
|
2033 | 101 |
dres_inst_tac [("f",dname^"_abs")] cfun_arg_cong 1, |
102 |
etac (ax_rep_iso RS subst) 1]; |
|
1274 | 103 |
fun exh foldr1 cn quant foldr2 var = let |
104 |
fun one_con (con,args) = let val vns = map vname args in |
|
105 |
foldr quant (vns, foldr2 ((%x_name === con_app2 con (var vns) vns):: |
|
2033 | 106 |
map (defined o (var vns)) (nonlazy args))) end |
1274 | 107 |
in foldr1 ((cn(%x_name===UU))::map one_con cons) end; |
108 |
in |
|
4043 | 109 |
val casedist = let |
2033 | 110 |
fun common_tac thm = rtac thm 1 THEN contr_tac 1; |
2276 | 111 |
fun unit_tac true = common_tac upE1 |
2033 | 112 |
| unit_tac _ = all_tac; |
113 |
fun prod_tac [] = common_tac oneE |
|
114 |
| prod_tac [arg] = unit_tac (is_lazy arg) |
|
115 |
| prod_tac (arg::args) = |
|
116 |
common_tac sprodE THEN |
|
117 |
kill_neq_tac 1 THEN |
|
118 |
unit_tac (is_lazy arg) THEN |
|
119 |
prod_tac args; |
|
120 |
fun sum_rest_tac p = SELECT_GOAL(EVERY[ |
|
121 |
rtac p 1, |
|
122 |
rewrite_goals_tac axs_con_def, |
|
123 |
dtac iso_swap 1, |
|
124 |
simp_tac HOLCF_ss 1, |
|
8149
941afb897532
added tacticals DETERM_UNTIL and DETERM_UNTIL_SOLVED
oheimb
parents:
7906
diff
changeset
|
125 |
DETERM_UNTIL_SOLVED(fast_tac HOL_cs 1)]) 1; |
2033 | 126 |
fun sum_tac [(_,args)] [p] = |
127 |
prod_tac args THEN sum_rest_tac p |
|
128 |
| sum_tac ((_,args)::cons') (p::prems) = DETERM( |
|
129 |
common_tac ssumE THEN |
|
130 |
kill_neq_tac 1 THEN kill_neq_tac 2 THEN |
|
131 |
prod_tac args THEN sum_rest_tac p) THEN |
|
132 |
sum_tac cons' prems |
|
133 |
| sum_tac _ _ = Imposs "theorems:sum_tac"; |
|
134 |
in pg'' thy [] (exh (fn l => foldr (op ===>) (l,mk_trp(%"P"))) |
|
135 |
(fn T => T ==> %"P") mk_All |
|
136 |
(fn l => foldr (op ===>) (map mk_trp l, |
|
137 |
mk_trp(%"P"))) |
|
138 |
bound_arg) |
|
139 |
(fn prems => [ |
|
140 |
cut_facts_tac [excluded_middle] 1, |
|
141 |
etac disjE 1, |
|
142 |
rtac (hd prems) 2, |
|
143 |
etac rep_defin' 2, |
|
144 |
if length cons = 1 andalso |
|
145 |
length (snd(hd cons)) = 1 andalso |
|
146 |
not(is_lazy(hd(snd(hd cons)))) |
|
147 |
then rtac (hd (tl prems)) 1 THEN atac 2 THEN |
|
148 |
rewrite_goals_tac axs_con_def THEN |
|
149 |
simp_tac (HOLCF_ss addsimps [ax_rep_iso]) 1 |
|
150 |
else sum_tac cons (tl prems)])end; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
151 |
val exhaust= pg[](mk_trp(exh (foldr' mk_disj) Id mk_ex (foldr' mk_conj) (K %)))[ |
4043 | 152 |
rtac casedist 1, |
8149
941afb897532
added tacticals DETERM_UNTIL and DETERM_UNTIL_SOLVED
oheimb
parents:
7906
diff
changeset
|
153 |
DETERM_UNTIL_SOLVED(fast_tac HOL_cs 1)]; |
1274 | 154 |
end; |
155 |
||
156 |
local |
|
1834 | 157 |
fun bind_fun t = foldr mk_All (when_funs cons,t); |
1829 | 158 |
fun bound_fun i _ = Bound (length cons - i); |
159 |
val when_app = foldl (op `) (%%(dname^"_when"), mapn bound_fun 1 cons); |
|
160 |
val when_appl = pg [ax_when_def] (bind_fun(mk_trp(when_app`%x_name === |
|
2033 | 161 |
when_body cons (fn (m,n)=> bound_fun (n-m) 0)`(dc_rep`%x_name))))[ |
162 |
simp_tac HOLCF_ss 1]; |
|
1274 | 163 |
in |
1829 | 164 |
val when_strict = pg [] (bind_fun(mk_trp(strict when_app))) [ |
2033 | 165 |
simp_tac(HOLCF_ss addsimps [when_appl,rep_strict]) 1]; |
1829 | 166 |
val when_apps = let fun one_when n (con,args) = pg axs_con_def |
2033 | 167 |
(bind_fun (lift_defined % (nonlazy args, |
168 |
mk_trp(when_app`(con_app con args) === |
|
5291 | 169 |
mk_cRep_CFun(bound_fun n 0,map %# args)))))[ |
2033 | 170 |
asm_simp_tac (HOLCF_ss addsimps [when_appl,ax_abs_iso]) 1]; |
171 |
in mapn one_when 1 cons end; |
|
1274 | 172 |
end; |
173 |
val when_rews = when_strict::when_apps; |
|
174 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
175 |
(* ----- theorems concerning the constructors, discriminators and selectors - *) |
1274 | 176 |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
177 |
val dis_rews = let |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
178 |
val dis_stricts = map (fn (con,_) => pg axs_dis_def (mk_trp( |
2033 | 179 |
strict(%%(dis_name con)))) [ |
180 |
simp_tac (HOLCF_ss addsimps when_rews) 1]) cons; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
181 |
val dis_apps = let fun one_dis c (con,args)= pg axs_dis_def |
2033 | 182 |
(lift_defined % (nonlazy args, |
183 |
(mk_trp((%%(dis_name c))`(con_app con args) === |
|
184 |
%%(if con=c then "TT" else "FF"))))) [ |
|
185 |
asm_simp_tac (HOLCF_ss addsimps when_rews) 1]; |
|
186 |
in flat(map (fn (c,_) => map (one_dis c) cons) cons) end; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
187 |
val dis_defins = map (fn (con,args) => pg [] (defined(%x_name) ==> |
2033 | 188 |
defined(%%(dis_name con)`%x_name)) [ |
4043 | 189 |
rtac casedist 1, |
2033 | 190 |
contr_tac 1, |
8149
941afb897532
added tacticals DETERM_UNTIL and DETERM_UNTIL_SOLVED
oheimb
parents:
7906
diff
changeset
|
191 |
DETERM_UNTIL_SOLVED (CHANGED(asm_simp_tac |
2033 | 192 |
(HOLCF_ss addsimps dis_apps) 1))]) cons; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
193 |
in dis_stricts @ dis_defins @ dis_apps end; |
1274 | 194 |
|
195 |
val con_stricts = flat(map (fn (con,args) => map (fn vn => |
|
2033 | 196 |
pg (axs_con_def) |
197 |
(mk_trp(con_app2 con (fn arg => if vname arg = vn |
|
198 |
then UU else %# arg) args === UU))[ |
|
199 |
asm_simp_tac (HOLCF_ss addsimps [abs_strict]) 1] |
|
200 |
) (nonlazy args)) cons); |
|
1274 | 201 |
val con_defins = map (fn (con,args) => pg [] |
2033 | 202 |
(lift_defined % (nonlazy args, |
203 |
mk_trp(defined(con_app con args)))) ([ |
|
2445
51993fea433f
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents:
2276
diff
changeset
|
204 |
rtac rev_contrapos 1, |
2033 | 205 |
eres_inst_tac [("f",dis_name con)] cfun_arg_cong 1, |
206 |
asm_simp_tac (HOLCF_ss addsimps dis_rews) 1] )) cons; |
|
1274 | 207 |
val con_rews = con_stricts @ con_defins; |
208 |
||
209 |
val sel_stricts = let fun one_sel sel = pg axs_sel_def (mk_trp(strict(%%sel))) [ |
|
2033 | 210 |
simp_tac (HOLCF_ss addsimps when_rews) 1]; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
211 |
in flat(map (fn (_,args) =>map (fn arg => one_sel (sel_of arg)) args) cons) end; |
1274 | 212 |
val sel_apps = let fun one_sel c n sel = map (fn (con,args) => |
2033 | 213 |
let val nlas = nonlazy args; |
214 |
val vns = map vname args; |
|
215 |
in pg axs_sel_def (lift_defined % |
|
216 |
(filter (fn v => con=c andalso (v<>nth_elem(n,vns))) nlas, |
|
217 |
mk_trp((%%sel)`(con_app con args) === |
|
218 |
(if con=c then %(nth_elem(n,vns)) else UU)))) |
|
219 |
( (if con=c then [] |
|
220 |
else map(case_UU_tac(when_rews@con_stricts)1) nlas) |
|
221 |
@(if con=c andalso ((nth_elem(n,vns)) mem nlas) |
|
222 |
then[case_UU_tac (when_rews @ con_stricts) 1 |
|
223 |
(nth_elem(n,vns))] else []) |
|
224 |
@ [asm_simp_tac(HOLCF_ss addsimps when_rews)1])end) cons; |
|
1274 | 225 |
in flat(map (fn (c,args) => |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
226 |
flat(mapn (fn n => fn arg => one_sel c n (sel_of arg)) 0 args)) cons) end; |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
227 |
val sel_defins = if length cons=1 then map (fn arg => pg [](defined(%x_name)==> |
2033 | 228 |
defined(%%(sel_of arg)`%x_name)) [ |
4043 | 229 |
rtac casedist 1, |
2033 | 230 |
contr_tac 1, |
8149
941afb897532
added tacticals DETERM_UNTIL and DETERM_UNTIL_SOLVED
oheimb
parents:
7906
diff
changeset
|
231 |
DETERM_UNTIL_SOLVED (CHANGED(asm_simp_tac |
2033 | 232 |
(HOLCF_ss addsimps sel_apps) 1))]) |
233 |
(filter_out is_lazy (snd(hd cons))) else []; |
|
1274 | 234 |
val sel_rews = sel_stricts @ sel_defins @ sel_apps; |
235 |
||
236 |
val distincts_le = let |
|
237 |
fun dist (con1, args1) (con2, args2) = pg [] |
|
2033 | 238 |
(lift_defined % ((nonlazy args1), |
239 |
(mk_trp (con_app con1 args1 ~<< con_app con2 args2))))([ |
|
2445
51993fea433f
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents:
2276
diff
changeset
|
240 |
rtac rev_contrapos 1, |
2033 | 241 |
eres_inst_tac[("fo",dis_name con1)] monofun_cfun_arg 1] |
242 |
@map(case_UU_tac (con_stricts @ dis_rews)1)(nonlazy args2) |
|
243 |
@[asm_simp_tac (HOLCF_ss addsimps dis_rews) 1]); |
|
1274 | 244 |
fun distinct (con1,args1) (con2,args2) = |
2267 | 245 |
let val arg1 = (con1, args1) |
246 |
val arg2 = (con2, |
|
247 |
ListPair.map (fn (arg,vn) => upd_vname (K vn) arg) |
|
248 |
(args2, variantlist(map vname args2,map vname args1))) |
|
2033 | 249 |
in [dist arg1 arg2, dist arg2 arg1] end; |
1274 | 250 |
fun distincts [] = [] |
251 |
| distincts (c::cs) = (map (distinct c) cs) :: distincts cs; |
|
252 |
in distincts cons end; |
|
4043 | 253 |
val dist_les = flat (flat distincts_le); |
254 |
val dist_eqs = let |
|
1274 | 255 |
fun distinct (_,args1) ((_,args2),leqs) = let |
2033 | 256 |
val (le1,le2) = (hd leqs, hd(tl leqs)); |
257 |
val (eq1,eq2) = (le1 RS dist_eqI, le2 RS dist_eqI) in |
|
258 |
if nonlazy args1 = [] then [eq1, eq1 RS not_sym] else |
|
259 |
if nonlazy args2 = [] then [eq2, eq2 RS not_sym] else |
|
260 |
[eq1, eq2] end; |
|
4221 | 261 |
open BasisLibrary (*restore original List*) |
1274 | 262 |
fun distincts [] = [] |
4062 | 263 |
| distincts ((c,leqs)::cs) = List.concat |
2267 | 264 |
(ListPair.map (distinct c) ((map #1 cs),leqs)) @ |
265 |
distincts cs; |
|
1274 | 266 |
in distincts (cons~~distincts_le) end; |
267 |
||
268 |
local |
|
269 |
fun pgterm rel con args = let |
|
2033 | 270 |
fun append s = upd_vname(fn v => v^s); |
271 |
val (largs,rargs) = (args, map (append "'") args); |
|
272 |
in pg [] (mk_trp (rel(con_app con largs,con_app con rargs)) ===> |
|
273 |
lift_defined % ((nonlazy largs),lift_defined % ((nonlazy rargs), |
|
274 |
mk_trp (foldr' mk_conj |
|
2267 | 275 |
(ListPair.map rel |
276 |
(map %# largs, map %# rargs)))))) end; |
|
1274 | 277 |
val cons' = filter (fn (_,args) => args<>[]) cons; |
278 |
in |
|
279 |
val inverts = map (fn (con,args) => |
|
2033 | 280 |
pgterm (op <<) con args (flat(map (fn arg => [ |
281 |
TRY(rtac conjI 1), |
|
282 |
dres_inst_tac [("fo",sel_of arg)] monofun_cfun_arg 1, |
|
283 |
asm_full_simp_tac (HOLCF_ss addsimps sel_apps) 1] |
|
284 |
) args))) cons'; |
|
1274 | 285 |
val injects = map (fn ((con,args),inv_thm) => |
2033 | 286 |
pgterm (op ===) con args [ |
287 |
etac (antisym_less_inverse RS conjE) 1, |
|
288 |
dtac inv_thm 1, REPEAT(atac 1), |
|
289 |
dtac inv_thm 1, REPEAT(atac 1), |
|
290 |
TRY(safe_tac HOL_cs), |
|
291 |
REPEAT(rtac antisym_less 1 ORELSE atac 1)] ) |
|
292 |
(cons'~~inverts); |
|
1274 | 293 |
end; |
294 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
295 |
(* ----- theorems concerning one induction step ----------------------------- *) |
1274 | 296 |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
297 |
val copy_strict = pg[ax_copy_def](mk_trp(strict(dc_copy`%"f"))) [ |
2033 | 298 |
asm_simp_tac(HOLCF_ss addsimps [abs_strict, when_strict, |
299 |
cfst_strict,csnd_strict]) 1]; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
300 |
val copy_apps = map (fn (con,args) => pg [ax_copy_def] |
2033 | 301 |
(lift_defined % (nonlazy_rec args, |
302 |
mk_trp(dc_copy`%"f"`(con_app con args) === |
|
4755 | 303 |
(con_app2 con (app_rec_arg (cproj (%"f") eqs)) args)))) |
2033 | 304 |
(map (case_UU_tac (abs_strict::when_strict::con_stricts) |
305 |
1 o vname) |
|
306 |
(filter (fn a => not (is_rec a orelse is_lazy a)) args) |
|
307 |
@[asm_simp_tac (HOLCF_ss addsimps when_apps) 1, |
|
308 |
simp_tac (HOLCF_ss addsimps axs_con_def) 1]))cons; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
309 |
val copy_stricts = map (fn (con,args) => pg [] (mk_trp(dc_copy`UU` |
2033 | 310 |
(con_app con args) ===UU)) |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
311 |
(let val rews = cfst_strict::csnd_strict::copy_strict::copy_apps@con_rews |
2033 | 312 |
in map (case_UU_tac rews 1) (nonlazy args) @ [ |
313 |
asm_simp_tac (HOLCF_ss addsimps rews) 1] end)) |
|
314 |
(filter (fn (_,args)=>exists is_nonlazy_rec args) cons); |
|
1274 | 315 |
val copy_rews = copy_strict::copy_apps @ copy_stricts; |
4043 | 316 |
in thy |> Theory.add_path (Sign.base_name dname) |
8438 | 317 |
|> (#1 o (PureThy.add_thmss (map Thm.no_attributes [ |
4043 | 318 |
("iso_rews" , iso_rews ), |
319 |
("exhaust" , [exhaust] ), |
|
320 |
("casedist" , [casedist]), |
|
321 |
("when_rews", when_rews ), |
|
322 |
("con_rews", con_rews), |
|
323 |
("sel_rews", sel_rews), |
|
324 |
("dis_rews", dis_rews), |
|
325 |
("dist_les", dist_les), |
|
326 |
("dist_eqs", dist_eqs), |
|
327 |
("inverts" , inverts ), |
|
328 |
("injects" , injects ), |
|
8438 | 329 |
("copy_rews", copy_rews)]))) |
4861 | 330 |
|> Theory.parent_path |
1274 | 331 |
end; (* let *) |
332 |
||
4043 | 333 |
fun comp_theorems (comp_dnam, eqs: eq list) thy = |
1274 | 334 |
let |
4008 | 335 |
val dnames = map (fst o fst) eqs; |
336 |
val conss = map snd eqs; |
|
337 |
val comp_dname = Sign.full_name (sign_of thy) comp_dnam; |
|
338 |
||
4030 | 339 |
val d = writeln("Proving induction properties of domain "^comp_dname^" ..."); |
1274 | 340 |
val pg = pg' thy; |
341 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
342 |
(* ----- getting the composite axiom and definitions ------------------------ *) |
1274 | 343 |
|
7906 | 344 |
local fun ga s dn = get_thm thy (dn^"."^s) in |
4043 | 345 |
val axs_reach = map (ga "reach" ) dnames; |
346 |
val axs_take_def = map (ga "take_def" ) dnames; |
|
347 |
val axs_finite_def = map (ga "finite_def") dnames; |
|
348 |
val ax_copy2_def = ga "copy_def" comp_dnam; |
|
349 |
val ax_bisim_def = ga "bisim_def" comp_dnam; |
|
350 |
end; (* local *) |
|
351 |
||
352 |
local fun gt s dn = get_thm thy (dn^"."^s); |
|
353 |
fun gts s dn = get_thms thy (dn^"."^s) in |
|
354 |
val cases = map (gt "casedist" ) dnames; |
|
355 |
val con_rews = flat (map (gts "con_rews" ) dnames); |
|
356 |
val copy_rews = flat (map (gts "copy_rews") dnames); |
|
1274 | 357 |
end; (* local *) |
358 |
||
359 |
fun dc_take dn = %%(dn^"_take"); |
|
360 |
val x_name = idx_name dnames "x"; |
|
361 |
val P_name = idx_name dnames "P"; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
362 |
val n_eqs = length eqs; |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
363 |
|
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
364 |
(* ----- theorems concerning finite approximation and finite induction ------ *) |
1274 | 365 |
|
366 |
local |
|
4098 | 367 |
val iterate_Cprod_ss = simpset_of Fix.thy |
2033 | 368 |
addsimps [cfst_strict, csnd_strict]addsimps Cprod_rews; |
1274 | 369 |
val copy_con_rews = copy_rews @ con_rews; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
370 |
val copy_take_defs =(if n_eqs = 1 then [] else [ax_copy2_def]) @ axs_take_def; |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
371 |
val take_stricts=pg copy_take_defs(mk_trp(foldr' mk_conj(map(fn((dn,args),_)=> |
4030 | 372 |
strict(dc_take dn $ %"n")) eqs))) ([ |
2033 | 373 |
nat_ind_tac "n" 1, |
4030 | 374 |
simp_tac iterate_Cprod_ss 1, |
2033 | 375 |
asm_simp_tac (iterate_Cprod_ss addsimps copy_rews)1]); |
1274 | 376 |
val take_stricts' = rewrite_rule copy_take_defs take_stricts; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
377 |
val take_0s = mapn(fn n=> fn dn => pg axs_take_def(mk_trp((dc_take dn $ %%"0") |
2033 | 378 |
`%x_name n === UU))[ |
379 |
simp_tac iterate_Cprod_ss 1]) 1 dnames; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
380 |
val c_UU_tac = case_UU_tac (take_stricts'::copy_con_rews) 1; |
1274 | 381 |
val take_apps = pg copy_take_defs (mk_trp(foldr' mk_conj |
2033 | 382 |
(flat(map (fn ((dn,_),cons) => map (fn (con,args) => foldr mk_all |
383 |
(map vname args,(dc_take dn $ (%%"Suc" $ %"n"))`(con_app con args) === |
|
384 |
con_app2 con (app_rec_arg (fn n=>dc_take (nth_elem(n,dnames))$ %"n")) |
|
385 |
args)) cons) eqs)))) ([ |
|
386 |
simp_tac iterate_Cprod_ss 1, |
|
387 |
nat_ind_tac "n" 1, |
|
388 |
simp_tac(iterate_Cprod_ss addsimps copy_con_rews) 1, |
|
389 |
asm_full_simp_tac (HOLCF_ss addsimps |
|
390 |
(filter (has_fewer_prems 1) copy_rews)) 1, |
|
391 |
TRY(safe_tac HOL_cs)] @ |
|
392 |
(flat(map (fn ((dn,_),cons) => map (fn (con,args) => |
|
393 |
if nonlazy_rec args = [] then all_tac else |
|
394 |
EVERY(map c_UU_tac (nonlazy_rec args)) THEN |
|
395 |
asm_full_simp_tac (HOLCF_ss addsimps copy_rews)1 |
|
396 |
) cons) eqs))); |
|
1274 | 397 |
in |
398 |
val take_rews = atomize take_stricts @ take_0s @ atomize take_apps; |
|
399 |
end; (* local *) |
|
400 |
||
401 |
local |
|
402 |
fun one_con p (con,args) = foldr mk_All (map vname args, |
|
2033 | 403 |
lift_defined (bound_arg (map vname args)) (nonlazy args, |
404 |
lift (fn arg => %(P_name (1+rec_of arg)) $ bound_arg args arg) |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
405 |
(filter is_rec args,mk_trp(%p $ con_app2 con (bound_arg args) args)))); |
1274 | 406 |
fun one_eq ((p,cons),concl) = (mk_trp(%p $ UU) ===> |
2033 | 407 |
foldr (op ===>) (map (one_con p) cons,concl)); |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
408 |
fun ind_term concf = foldr one_eq (mapn (fn n => fn x => (P_name n, x))1conss, |
2033 | 409 |
mk_trp(foldr' mk_conj (mapn concf 1 dnames))); |
1274 | 410 |
val take_ss = HOL_ss addsimps take_rews; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
411 |
fun quant_tac i = EVERY(mapn(fn n=> fn _=> res_inst_tac[("x",x_name n)]spec i) |
2033 | 412 |
1 dnames); |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
413 |
fun ind_prems_tac prems = EVERY(flat (map (fn cons => ( |
2033 | 414 |
resolve_tac prems 1 :: |
415 |
flat (map (fn (_,args) => |
|
416 |
resolve_tac prems 1 :: |
|
417 |
map (K(atac 1)) (nonlazy args) @ |
|
418 |
map (K(atac 1)) (filter is_rec args)) |
|
419 |
cons))) conss)); |
|
1274 | 420 |
local |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
421 |
(* check whether every/exists constructor of the n-th part of the equation: |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
422 |
it has a possibly indirectly recursive argument that isn't/is possibly |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
423 |
indirectly lazy *) |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
424 |
fun rec_to quant nfn rfn ns lazy_rec (n,cons) = quant (exists (fn arg => |
2033 | 425 |
is_rec arg andalso not(rec_of arg mem ns) andalso |
426 |
((rec_of arg = n andalso nfn(lazy_rec orelse is_lazy arg)) orelse |
|
427 |
rec_of arg <> n andalso rec_to quant nfn rfn (rec_of arg::ns) |
|
428 |
(lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss)))) |
|
429 |
) o snd) cons; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
430 |
fun all_rec_to ns = rec_to forall not all_rec_to ns; |
4030 | 431 |
fun warn (n,cons) = if all_rec_to [] false (n,cons) then (warning |
432 |
("domain "^nth_elem(n,dnames)^" is empty!"); true) else false; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
433 |
fun lazy_rec_to ns = rec_to exists Id lazy_rec_to ns; |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
434 |
|
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
435 |
in val n__eqs = mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs; |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
436 |
val is_emptys = map warn n__eqs; |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
437 |
val is_finite = forall (not o lazy_rec_to [] false) n__eqs; |
1274 | 438 |
end; |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
439 |
in (* local *) |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
440 |
val finite_ind = pg'' thy [] (ind_term (fn n => fn dn => %(P_name n)$ |
2033 | 441 |
(dc_take dn $ %"n" `%(x_name n)))) (fn prems => [ |
442 |
quant_tac 1, |
|
2445
51993fea433f
removed Holcfb.thy and Holcfb.ML, moving classical3 to HOL.ML as classical2
oheimb
parents:
2276
diff
changeset
|
443 |
simp_tac HOL_ss 1, |
2033 | 444 |
nat_ind_tac "n" 1, |
445 |
simp_tac (take_ss addsimps prems) 1, |
|
446 |
TRY(safe_tac HOL_cs)] |
|
447 |
@ flat(map (fn (cons,cases) => [ |
|
448 |
res_inst_tac [("x","x")] cases 1, |
|
449 |
asm_simp_tac (take_ss addsimps prems) 1] |
|
450 |
@ flat(map (fn (con,args) => |
|
451 |
asm_simp_tac take_ss 1 :: |
|
452 |
map (fn arg => |
|
453 |
case_UU_tac (prems@con_rews) 1 ( |
|
10835 | 454 |
nth_elem(rec_of arg,dnames)^"_take n$"^vname arg)) |
2033 | 455 |
(filter is_nonlazy_rec args) @ [ |
456 |
resolve_tac prems 1] @ |
|
457 |
map (K (atac 1)) (nonlazy args) @ |
|
458 |
map (K (etac spec 1)) (filter is_rec args)) |
|
459 |
cons)) |
|
4043 | 460 |
(conss~~cases))); |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
461 |
|
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
462 |
val take_lemmas =mapn(fn n=> fn(dn,ax_reach)=> pg'' thy axs_take_def(mk_All("n", |
2033 | 463 |
mk_trp(dc_take dn $ Bound 0 `%(x_name n) === |
464 |
dc_take dn $ Bound 0 `%(x_name n^"'"))) |
|
465 |
===> mk_trp(%(x_name n) === %(x_name n^"'"))) (fn prems => [ |
|
466 |
res_inst_tac[("t",x_name n )](ax_reach RS subst) 1, |
|
467 |
res_inst_tac[("t",x_name n^"'")](ax_reach RS subst) 1, |
|
468 |
stac fix_def2 1, |
|
469 |
REPEAT(CHANGED(rtac(contlub_cfun_arg RS ssubst)1 |
|
470 |
THEN chain_tac 1)), |
|
471 |
stac contlub_cfun_fun 1, |
|
472 |
stac contlub_cfun_fun 2, |
|
473 |
rtac lub_equal 3, |
|
474 |
chain_tac 1, |
|
475 |
rtac allI 1, |
|
476 |
resolve_tac prems 1])) 1 (dnames~~axs_reach); |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
477 |
|
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
478 |
(* ----- theorems concerning finiteness and induction ----------------------- *) |
1274 | 479 |
|
480 |
val (finites,ind) = if is_finite then |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
481 |
let |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
482 |
fun take_enough dn = mk_ex ("n",dc_take dn $ Bound 0 ` %"x" === %"x"); |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
483 |
val finite_lemmas1a = map (fn dn => pg [] (mk_trp(defined (%"x")) ===> |
2033 | 484 |
mk_trp(mk_disj(mk_all("n",dc_take dn $ Bound 0 ` %"x" === UU), |
485 |
take_enough dn)) ===> mk_trp(take_enough dn)) [ |
|
486 |
etac disjE 1, |
|
487 |
etac notE 1, |
|
488 |
resolve_tac take_lemmas 1, |
|
489 |
asm_simp_tac take_ss 1, |
|
490 |
atac 1]) dnames; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
491 |
val finite_lemma1b = pg [] (mk_trp (mk_all("n",foldr' mk_conj (mapn |
2033 | 492 |
(fn n => fn ((dn,args),_) => mk_constrainall(x_name n,Type(dn,args), |
493 |
mk_disj(dc_take dn $ Bound 1 ` Bound 0 === UU, |
|
494 |
dc_take dn $ Bound 1 ` Bound 0 === Bound 0))) 1 eqs)))) ([ |
|
495 |
rtac allI 1, |
|
496 |
nat_ind_tac "n" 1, |
|
497 |
simp_tac take_ss 1, |
|
498 |
TRY(safe_tac(empty_cs addSEs[conjE] addSIs[conjI]))] @ |
|
499 |
flat(mapn (fn n => fn (cons,cases) => [ |
|
500 |
simp_tac take_ss 1, |
|
501 |
rtac allI 1, |
|
502 |
res_inst_tac [("x",x_name n)] cases 1, |
|
503 |
asm_simp_tac take_ss 1] @ |
|
504 |
flat(map (fn (con,args) => |
|
505 |
asm_simp_tac take_ss 1 :: |
|
506 |
flat(map (fn vn => [ |
|
507 |
eres_inst_tac [("x",vn)] all_dupE 1, |
|
508 |
etac disjE 1, |
|
509 |
asm_simp_tac (HOL_ss addsimps con_rews) 1, |
|
510 |
asm_simp_tac take_ss 1]) |
|
511 |
(nonlazy_rec args))) |
|
512 |
cons)) |
|
4043 | 513 |
1 (conss~~cases))); |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
514 |
val finites = map (fn (dn,l1b) => pg axs_finite_def (mk_trp( |
2033 | 515 |
%%(dn^"_finite") $ %"x"))[ |
516 |
case_UU_tac take_rews 1 "x", |
|
517 |
eresolve_tac finite_lemmas1a 1, |
|
518 |
step_tac HOL_cs 1, |
|
519 |
step_tac HOL_cs 1, |
|
520 |
cut_facts_tac [l1b] 1, |
|
521 |
fast_tac HOL_cs 1]) (dnames~~atomize finite_lemma1b); |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
522 |
in |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
523 |
(finites, |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
524 |
pg'' thy[](ind_term (fn n => fn dn => %(P_name n) $ %(x_name n)))(fn prems => |
2033 | 525 |
TRY(safe_tac HOL_cs) :: |
526 |
flat (map (fn (finite,fin_ind) => [ |
|
527 |
rtac(rewrite_rule axs_finite_def finite RS exE)1, |
|
528 |
etac subst 1, |
|
529 |
rtac fin_ind 1, |
|
530 |
ind_prems_tac prems]) |
|
531 |
(finites~~(atomize finite_ind)) )) |
|
1274 | 532 |
) end (* let *) else |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
533 |
(mapn (fn n => fn dn => read_instantiate_sg (sign_of thy) |
2033 | 534 |
[("P",dn^"_finite "^x_name n)] excluded_middle) 1 dnames, |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
535 |
pg'' thy [] (foldr (op ===>) (mapn (fn n => K(mk_trp(%%"adm" $ %(P_name n)))) |
2033 | 536 |
1 dnames, ind_term (fn n => fn dn => %(P_name n) $ %(x_name n)))) |
537 |
(fn prems => map (fn ax_reach => rtac (ax_reach RS subst) 1) |
|
538 |
axs_reach @ [ |
|
539 |
quant_tac 1, |
|
540 |
rtac (adm_impl_admw RS wfix_ind) 1, |
|
4030 | 541 |
REPEAT_DETERM(rtac adm_all2 1), |
542 |
REPEAT_DETERM(TRY(rtac adm_conj 1) THEN |
|
543 |
rtac adm_subst 1 THEN |
|
2033 | 544 |
cont_tacR 1 THEN resolve_tac prems 1), |
545 |
strip_tac 1, |
|
546 |
rtac (rewrite_rule axs_take_def finite_ind) 1, |
|
547 |
ind_prems_tac prems]) |
|
4755 | 548 |
handle ERROR => (warning "Cannot prove infinite induction rule"; refl)) |
1274 | 549 |
end; (* local *) |
550 |
||
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
551 |
(* ----- theorem concerning coinduction ------------------------------------- *) |
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
552 |
|
1274 | 553 |
local |
554 |
val xs = mapn (fn n => K (x_name n)) 1 dnames; |
|
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
555 |
fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1); |
1274 | 556 |
val take_ss = HOL_ss addsimps take_rews; |
4755 | 557 |
val sproj = prj (fn s => K("fst("^s^")")) (fn s => K("snd("^s^")")); |
1637
b8a8ae2e5de1
Updated: 01-Mar-96 when functional strictified, copy_def based on when_def
oheimb
parents:
1512
diff
changeset
|
558 |
val coind_lemma=pg[ax_bisim_def](mk_trp(mk_imp(%%(comp_dname^"_bisim") $ %"R", |
2033 | 559 |
foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs, |
4755 | 560 |
foldr mk_imp (mapn (fn n => K(proj (%"R") eqs n $ |
2033 | 561 |
bnd_arg n 0 $ bnd_arg n 1)) 0 dnames, |
562 |
foldr' mk_conj (mapn (fn n => fn dn => |
|
563 |
(dc_take dn $ %"n" `bnd_arg n 0 === |
|
564 |
(dc_take dn $ %"n" `bnd_arg n 1)))0 dnames)))))) |
|
565 |
([ rtac impI 1, |
|
566 |
nat_ind_tac "n" 1, |
|
567 |
simp_tac take_ss 1, |
|
568 |
safe_tac HOL_cs] @ |
|
569 |
flat(mapn (fn n => fn x => [ |
|
570 |
rotate_tac (n+1) 1, |
|
571 |
etac all2E 1, |
|
4755 | 572 |
eres_inst_tac [("P1", sproj "R" eqs n^ |
2033 | 573 |
" "^x^" "^x^"'")](mp RS disjE) 1, |
574 |
TRY(safe_tac HOL_cs), |
|
575 |
REPEAT(CHANGED(asm_simp_tac take_ss 1))]) |
|
576 |
0 xs)); |
|
1274 | 577 |
in |
578 |
val coind = pg [] (mk_trp(%%(comp_dname^"_bisim") $ %"R") ===> |
|
2033 | 579 |
foldr (op ===>) (mapn (fn n => fn x => |
4755 | 580 |
mk_trp(proj (%"R") eqs n $ %x $ %(x^"'"))) 0 xs, |
2033 | 581 |
mk_trp(foldr' mk_conj (map (fn x => %x === %(x^"'")) xs)))) ([ |
582 |
TRY(safe_tac HOL_cs)] @ |
|
583 |
flat(map (fn take_lemma => [ |
|
584 |
rtac take_lemma 1, |
|
585 |
cut_facts_tac [coind_lemma] 1, |
|
586 |
fast_tac HOL_cs 1]) |
|
587 |
take_lemmas)); |
|
1274 | 588 |
end; (* local *) |
589 |
||
590 |
||
4043 | 591 |
in thy |> Theory.add_path comp_dnam |
8438 | 592 |
|> (#1 o (PureThy.add_thmss (map Thm.no_attributes [ |
4043 | 593 |
("take_rews" , take_rews ), |
594 |
("take_lemmas", take_lemmas), |
|
595 |
("finites" , finites ), |
|
596 |
("finite_ind", [finite_ind]), |
|
597 |
("ind" , [ind ]), |
|
8438 | 598 |
("coind" , [coind ])]))) |
4861 | 599 |
|> Theory.parent_path |
1274 | 600 |
end; (* let *) |
601 |
end; (* local *) |
|
602 |
end; (* struct *) |