author | nipkow |
Tue, 28 Mar 2000 17:31:36 +0200 | |
changeset 8600 | a466c687c726 |
parent 8177 | e59e93ad85eb |
child 10962 | cda180b1e2e0 |
permissions | -rw-r--r-- |
oheimb@8177 | 1 |
(* Title: HOL/IMPP/Misc.ML |
oheimb@8177 | 2 |
ID: $Id$ |
oheimb@8177 | 3 |
Author: David von Oheimb |
oheimb@8177 | 4 |
Copyright 1999 TUM |
oheimb@8177 | 5 |
*) |
oheimb@8177 | 6 |
|
oheimb@8177 | 7 |
section "state access"; |
oheimb@8177 | 8 |
|
oheimb@8177 | 9 |
Goalw [getlocs_def] "getlocs (st g l) = l"; |
oheimb@8177 | 10 |
by (Simp_tac 1); |
oheimb@8177 | 11 |
qed "getlocs_def2"; |
oheimb@8177 | 12 |
|
oheimb@8177 | 13 |
Goalw [update_def] "s[Loc Y::=s<Y>] = s"; |
oheimb@8177 | 14 |
by (induct_tac "s" 1); |
oheimb@8177 | 15 |
by (simp_tac (simpset() addsimps [getlocs_def2]) 1); |
oheimb@8177 | 16 |
qed "update_Loc_idem2"; |
oheimb@8177 | 17 |
Addsimps[update_Loc_idem2]; |
oheimb@8177 | 18 |
|
oheimb@8177 | 19 |
Goalw [update_def] "s[X::=x][X::=y] = s[X::=y]"; |
oheimb@8177 | 20 |
by (induct_tac "X" 1); |
oheimb@8177 | 21 |
by Auto_tac; |
oheimb@8177 | 22 |
by (ALLGOALS (induct_tac "s")); |
oheimb@8177 | 23 |
by Auto_tac; |
oheimb@8177 | 24 |
by (ALLGOALS (rtac ext)); |
oheimb@8177 | 25 |
by Auto_tac; |
oheimb@8177 | 26 |
qed "update_overwrt"; |
oheimb@8177 | 27 |
Addsimps[update_overwrt]; |
oheimb@8177 | 28 |
|
oheimb@8177 | 29 |
Goalw [update_def]"(s[Loc Y::=k])<Y'> = (if Y=Y' then k else s<Y'>)"; |
oheimb@8177 | 30 |
by (induct_tac "s" 1); |
oheimb@8177 | 31 |
by (simp_tac (simpset() addsimps [getlocs_def2]) 1); |
oheimb@8177 | 32 |
qed "getlocs_Loc_update"; |
oheimb@8177 | 33 |
Addsimps[getlocs_Loc_update]; |
oheimb@8177 | 34 |
|
oheimb@8177 | 35 |
Goalw [update_def] "getlocs (s[Glb Y::=k]) = getlocs s"; |
oheimb@8177 | 36 |
by (induct_tac "s" 1); |
oheimb@8177 | 37 |
by (simp_tac (simpset() addsimps [getlocs_def2]) 1); |
oheimb@8177 | 38 |
qed "getlocs_Glb_update"; |
oheimb@8177 | 39 |
Addsimps[getlocs_Glb_update]; |
oheimb@8177 | 40 |
|
oheimb@8177 | 41 |
Goalw [setlocs_def] "getlocs (setlocs s l) = l"; |
oheimb@8177 | 42 |
by (induct_tac "s" 1); |
oheimb@8177 | 43 |
by Auto_tac; |
oheimb@8177 | 44 |
by (simp_tac (simpset() addsimps [getlocs_def2]) 1); |
oheimb@8177 | 45 |
qed "getlocs_setlocs"; |
oheimb@8177 | 46 |
Addsimps[getlocs_setlocs]; |
oheimb@8177 | 47 |
|
oheimb@8177 | 48 |
Goal "getlocs (setlocs s (getlocs s')[Y::=k]) = getlocs (s'[Y::=k])"; |
oheimb@8177 | 49 |
by (induct_tac "Y" 1); |
oheimb@8177 | 50 |
br ext 2; |
oheimb@8177 | 51 |
by Auto_tac; |
oheimb@8177 | 52 |
qed "getlocs_setlocs_lemma"; |
oheimb@8177 | 53 |
|
oheimb@8177 | 54 |
(*unused*) |
oheimb@8177 | 55 |
Goalw [hoare_valids_def] |
oheimb@8177 | 56 |
"!v. G|={%Z s. P Z (s[Loc Y::=v]) & s<Y> = a (s[Loc Y::=v])}. \ |
oheimb@8177 | 57 |
\ c .{%Z s. Q Z (s[Loc Y::=v])} ==> G|={P}. LOCAL Y:=a IN c .{Q}"; |
oheimb@8177 | 58 |
by (full_simp_tac (simpset() addsimps [triple_valid_def2]) 1); |
oheimb@8177 | 59 |
by (Clarsimp_tac 1); |
oheimb@8177 | 60 |
by (dres_inst_tac [("x","s<Y>")] spec 1); |
oheimb@8177 | 61 |
by (smp_tac 1 1); |
oheimb@8177 | 62 |
bd spec 1; |
oheimb@8177 | 63 |
by (dres_inst_tac [("x","s[Loc Y::=a s]")] spec 1); |
oheimb@8177 | 64 |
by (Full_simp_tac 1); |
oheimb@8177 | 65 |
by (mp_tac 1); |
oheimb@8177 | 66 |
by (smp_tac 1 1); |
oheimb@8177 | 67 |
by (Simp_tac 1); |
oheimb@8177 | 68 |
qed "classic_Local_valid"; |
oheimb@8177 | 69 |
|
oheimb@8177 | 70 |
Goal "!v. G|-{%Z s. P Z (s[Loc Y::=v]) & s<Y> = a (s[Loc Y::=v])}. \ |
oheimb@8177 | 71 |
\ c .{%Z s. Q Z (s[Loc Y::=v])} ==> G|-{P}. LOCAL Y:=a IN c .{Q}"; |
oheimb@8177 | 72 |
br export_s 1; |
oheimb@8177 | 73 |
(*variant 1*) |
oheimb@8177 | 74 |
br (hoare_derivs.Local RS conseq1) 1; |
oheimb@8177 | 75 |
be spec 1; |
oheimb@8177 | 76 |
by (Force_tac 1); |
oheimb@8177 | 77 |
(*variant 2 |
oheimb@8177 | 78 |
by (res_inst_tac [("P'","%Z s. s' = s & P Z (s[Loc Y::=a s][Loc Y::=s'<Y>]) & (s[Loc Y::=a s])<Y> = a (s[Loc Y::=a s][Loc Y::=s'<Y>])")] conseq1 1); |
oheimb@8177 | 79 |
by (Clarsimp_tac 2); |
oheimb@8177 | 80 |
br hoare_derivs.Local 1; |
oheimb@8177 | 81 |
be spec 1; |
oheimb@8177 | 82 |
*) |
oheimb@8177 | 83 |
qed "classic_Local"; |
oheimb@8177 | 84 |
|
oheimb@8177 | 85 |
Goal "[| Y~=Y'; G|-{P}. c .{%Z s. s<Y'>=d} |] ==> \ |
oheimb@8177 | 86 |
\ G|-{%Z s. P Z (s[Loc Y::=a s])}. LOCAL Y:=a IN c .{%Z s. s<Y'>=d}"; |
oheimb@8177 | 87 |
br classic_Local 1; |
oheimb@8177 | 88 |
by (ALLGOALS Clarsimp_tac); |
oheimb@8177 | 89 |
be conseq12 1; |
oheimb@8177 | 90 |
by (Clarsimp_tac 1); |
oheimb@8177 | 91 |
bd sym 1; |
oheimb@8177 | 92 |
by (Asm_full_simp_tac 1); |
oheimb@8177 | 93 |
qed "classic_Local_indep"; |
oheimb@8177 | 94 |
|
oheimb@8177 | 95 |
Goal "[| Y~=Y'; G|-{P}. c .{%Z s. s<Y'>=d} |] ==> \ |
oheimb@8177 | 96 |
\ G|-{%Z s. P Z (s[Loc Y::=a s])}. LOCAL Y:=a IN c .{%Z s. s<Y'>=d}"; |
oheimb@8177 | 97 |
br export_s 1; |
oheimb@8177 | 98 |
br hoare_derivs.Local 1; |
oheimb@8177 | 99 |
by (Clarsimp_tac 1); |
oheimb@8177 | 100 |
qed "Local_indep"; |
oheimb@8177 | 101 |
|
oheimb@8177 | 102 |
Goal "[| Y'~=Y; G|-{P}. c .{%Z s. s<Y'>=d} |] ==> \ |
oheimb@8177 | 103 |
\ G|-{%Z s. P Z (s[Loc Y::=a s])}. LOCAL Y:=a IN c .{%Z s. s<Y'>=d}"; |
oheimb@8177 | 104 |
br weak_Local 1; |
oheimb@8177 | 105 |
by (ALLGOALS Clarsimp_tac); |
oheimb@8177 | 106 |
qed "weak_Local_indep"; |
oheimb@8177 | 107 |
|
oheimb@8177 | 108 |
|
oheimb@8177 | 109 |
Goal "G|-{%Z s. Z = s<Y>}. LOCAL Y:=a IN c .{%Z s. Z = s<Y>}"; |
oheimb@8177 | 110 |
br export_s 1; |
oheimb@8177 | 111 |
by (res_inst_tac [("P'","%Z s. s'=s & True"), ("Q'","%Z s. s'<Y> = s<Y>")] (conseq12) 1); |
oheimb@8177 | 112 |
by (Clarsimp_tac 2); |
oheimb@8177 | 113 |
br hoare_derivs.Local 1; |
oheimb@8177 | 114 |
by (Clarsimp_tac 1); |
oheimb@8177 | 115 |
br trueI 1; |
oheimb@8177 | 116 |
qed "export_Local_invariant"; |
oheimb@8177 | 117 |
|
oheimb@8177 | 118 |
Goal "G|-{%Z s. Z = s<Y>}. LOCAL Y:=a IN c .{%Z s. Z = s<Y>}"; |
oheimb@8177 | 119 |
br classic_Local 1; |
oheimb@8177 | 120 |
by (Clarsimp_tac 1); |
oheimb@8177 | 121 |
br (trueI RS conseq12) 1; |
oheimb@8177 | 122 |
by (Clarsimp_tac 1); |
oheimb@8177 | 123 |
qed "classic_Local_invariant"; |
oheimb@8177 | 124 |
|
oheimb@8177 | 125 |
Goal "G|-{P}. BODY pn .{%Z s. Q Z (setlocs s (getlocs s')[X::=s<Res>])} ==> \ |
oheimb@8177 | 126 |
\ G|-{%Z s. s'=s & I Z (getlocs (s[X::=k Z])) & P Z (setlocs s newlocs[Loc Arg::=a s])}. \ |
oheimb@8177 | 127 |
\ X:=CALL pn (a) .{%Z s. I Z (getlocs (s[X::=k Z])) & Q Z s}"; |
oheimb@8177 | 128 |
by (res_inst_tac [("s'1","s'"),("Q'","%Z s. I Z (getlocs (s[X::=k Z])) = I Z (getlocs (s'[X::=k Z])) & Q Z s")] (hoare_derivs.Call RS conseq12) 1); |
oheimb@8177 | 129 |
by (asm_simp_tac (simpset() addsimps [getlocs_setlocs_lemma]) 1); |
oheimb@8177 | 130 |
by (Force_tac 1); |
oheimb@8177 | 131 |
qed "Call_invariant"; |
oheimb@8177 | 132 |
|
oheimb@8177 | 133 |