author | paulson |
Wed, 05 Nov 1997 13:14:15 +0100 | |
changeset 4152 | 451104c223e2 |
parent 4091 | 771b1f6422a8 |
child 4298 | b69eedd3aa6c |
permissions | -rw-r--r-- |
1461 | 1 |
(* Title: ZF/IMP/Equiv.ML |
482 | 2 |
ID: $Id$ |
1461 | 3 |
Author: Heiko Loetzbeyer & Robert Sandner, TUM |
482 | 4 |
Copyright 1994 TUM |
5 |
*) |
|
6 |
||
511 | 7 |
val prems = goal Equiv.thy "[| a: aexp; sigma: loc -> nat |] ==> \ |
518 | 8 |
\ <a,sigma> -a-> n <-> A(a,sigma) = n"; |
511 | 9 |
by (res_inst_tac [("x","n")] spec 1); (* quantify n *) |
10 |
by (res_inst_tac [("x","a")] aexp.induct 1); (* struct. ind. *) |
|
11 |
by (resolve_tac prems 1); (* type prem. *) |
|
1461 | 12 |
by (rewrite_goals_tac A_rewrite_rules); (* rewr. Den. *) |
4091 | 13 |
by (TRYALL (fast_tac (claset() addSIs (evala.intrs@prems) |
2469 | 14 |
addSEs aexp_elim_cases))); |
760 | 15 |
qed "aexp_iff"; |
482 | 16 |
|
17 |
||
518 | 18 |
val aexp1 = prove_goal Equiv.thy |
19 |
"[| <a,sigma> -a-> n; a: aexp; sigma: loc -> nat |] \ |
|
1461 | 20 |
\ ==> A(a,sigma) = n" (* destruction rule *) |
4091 | 21 |
(fn prems => [(fast_tac (claset() addSIs ((aexp_iff RS iffD1)::prems)) 1)]); |
482 | 22 |
val aexp2 = aexp_iff RS iffD2; |
23 |
||
24 |
||
511 | 25 |
val bexp_elim_cases = |
482 | 26 |
[ |
511 | 27 |
evalb.mk_cases bexp.con_defs "<true,sigma> -b-> x", |
28 |
evalb.mk_cases bexp.con_defs "<false,sigma> -b-> x", |
|
29 |
evalb.mk_cases bexp.con_defs "<ROp(f,a0,a1),sigma> -b-> x", |
|
30 |
evalb.mk_cases bexp.con_defs "<noti(b),sigma> -b-> x", |
|
31 |
evalb.mk_cases bexp.con_defs "<b0 andi b1,sigma> -b-> x", |
|
32 |
evalb.mk_cases bexp.con_defs "<b0 ori b1,sigma> -b-> x" |
|
482 | 33 |
]; |
34 |
||
35 |
||
36 |
val prems = goal Equiv.thy "[| b: bexp; sigma: loc -> nat |] ==> \ |
|
518 | 37 |
\ <b,sigma> -b-> w <-> B(b,sigma) = w"; |
1461 | 38 |
by (res_inst_tac [("x","w")] spec 1); (* quantify w *) |
39 |
by (res_inst_tac [("x","b")] bexp.induct 1); (* struct. ind. *) |
|
40 |
by (resolve_tac prems 1); (* type prem. *) |
|
41 |
by (rewrite_goals_tac B_rewrite_rules); (* rewr. Den. *) |
|
4091 | 42 |
by (TRYALL (fast_tac (claset() addSIs (evalb.intrs@prems@[aexp2]) |
518 | 43 |
addSDs [aexp1] addSEs bexp_elim_cases))); |
760 | 44 |
qed "bexp_iff"; |
482 | 45 |
|
511 | 46 |
val bexp1 = prove_goal Equiv.thy |
518 | 47 |
"[| <b,sigma> -b-> w; b: bexp; sigma: loc -> nat |]\ |
48 |
\ ==> B(b,sigma) = w" |
|
4091 | 49 |
(fn prems => [(fast_tac (claset() addSIs ((bexp_iff RS iffD1)::prems)) 1)]); |
518 | 50 |
val bexp2 = bexp_iff RS iffD2; |
482 | 51 |
|
518 | 52 |
goal Equiv.thy "!!c. <c,sigma> -c-> sigma' ==> <sigma,sigma'> : C(c)"; |
482 | 53 |
|
500 | 54 |
(* start with rule induction *) |
1742 | 55 |
by (etac evalc.induct 1); |
482 | 56 |
|
500 | 57 |
by (rewrite_tac (Gamma_def::C_rewrite_rules)); |
482 | 58 |
(* skip *) |
2469 | 59 |
by (Fast_tac 1); |
500 | 60 |
|
482 | 61 |
(* assign *) |
4091 | 62 |
by (asm_full_simp_tac (simpset() addsimps [aexp1,assign_type] @ op_type_intrs) 1); |
672
1922f98b8f7e
com1,2: added simplifier calls to remove use of ssubst in fast_tac
lcp
parents:
518
diff
changeset
|
63 |
|
482 | 64 |
(* comp *) |
2469 | 65 |
by (Fast_tac 1); |
482 | 66 |
|
67 |
(* if *) |
|
4091 | 68 |
by (asm_simp_tac (simpset() addsimps [bexp1]) 1); |
69 |
by (asm_simp_tac (simpset() addsimps [bexp1]) 1); |
|
482 | 70 |
|
71 |
(* while *) |
|
672
1922f98b8f7e
com1,2: added simplifier calls to remove use of ssubst in fast_tac
lcp
parents:
518
diff
changeset
|
72 |
by (etac (rewrite_rule [Gamma_def] |
1461 | 73 |
(Gamma_bnd_mono RS lfp_Tarski RS ssubst)) 1); |
4091 | 74 |
by (asm_simp_tac (simpset() addsimps [bexp1]) 1); |
75 |
by (fast_tac (claset() addSIs [bexp1,idI]@evalb_type_intrs) 1); |
|
482 | 76 |
|
672
1922f98b8f7e
com1,2: added simplifier calls to remove use of ssubst in fast_tac
lcp
parents:
518
diff
changeset
|
77 |
by (etac (rewrite_rule [Gamma_def] |
1461 | 78 |
(Gamma_bnd_mono RS lfp_Tarski RS ssubst)) 1); |
4091 | 79 |
by (asm_simp_tac (simpset() addsimps [bexp1]) 1); |
80 |
by (fast_tac (claset() addSIs [bexp1,compI]@evalb_type_intrs) 1); |
|
482 | 81 |
|
500 | 82 |
val com1 = result(); |
482 | 83 |
|
84 |
||
2469 | 85 |
AddSIs [aexp2,bexp2,B_type,A_type]; |
86 |
AddIs evalc.intrs; |
|
87 |
AddEs [C_type,C_type_fst]; |
|
482 | 88 |
|
511 | 89 |
val [prem] = goal Equiv.thy |
518 | 90 |
"c : com ==> ALL x:C(c). <c,fst(x)> -c-> snd(x)"; |
808 | 91 |
by (rtac (prem RS com.induct) 1); |
482 | 92 |
by (rewrite_tac C_rewrite_rules); |
4152 | 93 |
by Safe_tac; |
2469 | 94 |
by (ALLGOALS Asm_full_simp_tac); |
482 | 95 |
|
96 |
(* skip *) |
|
2469 | 97 |
by (Fast_tac 1); |
500 | 98 |
|
482 | 99 |
(* assign *) |
2469 | 100 |
by (Fast_tac 1); |
500 | 101 |
|
482 | 102 |
(* comp *) |
518 | 103 |
by (REPEAT (EVERY [(dtac bspec 1),(atac 1)])); |
2469 | 104 |
by (Asm_full_simp_tac 1); |
105 |
by (Fast_tac 1); |
|
500 | 106 |
|
482 | 107 |
(* while *) |
518 | 108 |
by (EVERY1 [forward_tac [Gamma_bnd_mono], etac induct, atac]); |
808 | 109 |
by (rewtac Gamma_def); |
4152 | 110 |
by Safe_tac; |
518 | 111 |
by (EVERY1 [dtac bspec, atac]); |
2469 | 112 |
by (ALLGOALS Asm_full_simp_tac); |
482 | 113 |
|
511 | 114 |
(* while, if *) |
2469 | 115 |
by (ALLGOALS Fast_tac); |
482 | 116 |
val com2 = result(); |
117 |
||
118 |
||
511 | 119 |
(**** Proof of Equivalence ****) |
482 | 120 |
|
511 | 121 |
goal Equiv.thy |
122 |
"ALL c:com. C(c) = {io:(loc->nat)*(loc->nat). <c,fst(io)> -c-> snd(io)}"; |
|
4091 | 123 |
by (fast_tac (claset() addIs [C_subset RS subsetD] |
2469 | 124 |
addEs [com2 RS bspec] |
125 |
addDs [com1] |
|
4091 | 126 |
addss (simpset())) 1); |
511 | 127 |
val com_equivalence = result(); |