author | bulwahn |
Wed, 14 Dec 2011 16:30:32 +0100 | |
changeset 45873 | 37ffb8797a63 |
parent 45212 | e87feee00a4c |
child 47818 | 151d137f1095 |
permissions | -rw-r--r-- |
44177
b4b5cbca2519
IMP/Util distinguishes between sets and functions again; imported only where used.
kleing
parents:
43158
diff
changeset
|
1 |
theory Procs_Dyn_Vars_Dyn imports Procs |
43158 | 2 |
begin |
3 |
||
4 |
subsubsection "Dynamic Scoping of Procedures and Variables" |
|
5 |
||
45212 | 6 |
type_synonym penv = "pname \<Rightarrow> com" |
43158 | 7 |
|
8 |
inductive |
|
9 |
big_step :: "penv \<Rightarrow> com \<times> state \<Rightarrow> state \<Rightarrow> bool" ("_ \<turnstile> _ \<Rightarrow> _" [60,0,60] 55) |
|
10 |
where |
|
11 |
Skip: "pe \<turnstile> (SKIP,s) \<Rightarrow> s" | |
|
12 |
Assign: "pe \<turnstile> (x ::= a,s) \<Rightarrow> s(x := aval a s)" | |
|
13 |
Semi: "\<lbrakk> pe \<turnstile> (c\<^isub>1,s\<^isub>1) \<Rightarrow> s\<^isub>2; pe \<turnstile> (c\<^isub>2,s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow> |
|
14 |
pe \<turnstile> (c\<^isub>1;c\<^isub>2, s\<^isub>1) \<Rightarrow> s\<^isub>3" | |
|
15 |
||
16 |
IfTrue: "\<lbrakk> bval b s; pe \<turnstile> (c\<^isub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow> |
|
17 |
pe \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" | |
|
18 |
IfFalse: "\<lbrakk> \<not>bval b s; pe \<turnstile> (c\<^isub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow> |
|
19 |
pe \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" | |
|
20 |
||
21 |
WhileFalse: "\<not>bval b s \<Longrightarrow> pe \<turnstile> (WHILE b DO c,s) \<Rightarrow> s" | |
|
22 |
WhileTrue: |
|
23 |
"\<lbrakk> bval b s\<^isub>1; pe \<turnstile> (c,s\<^isub>1) \<Rightarrow> s\<^isub>2; pe \<turnstile> (WHILE b DO c, s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow> |
|
24 |
pe \<turnstile> (WHILE b DO c, s\<^isub>1) \<Rightarrow> s\<^isub>3" | |
|
25 |
||
26 |
Var: "pe \<turnstile> (c,s) \<Rightarrow> t \<Longrightarrow> pe \<turnstile> ({VAR x;; c}, s) \<Rightarrow> t(x := s x)" | |
|
27 |
||
28 |
Call: "pe \<turnstile> (pe p, s) \<Rightarrow> t \<Longrightarrow> pe \<turnstile> (CALL p, s) \<Rightarrow> t" | |
|
29 |
||
30 |
Proc: "pe(p := cp) \<turnstile> (c,s) \<Rightarrow> t \<Longrightarrow> pe \<turnstile> ({PROC p = cp;; c}, s) \<Rightarrow> t" |
|
31 |
||
32 |
code_pred big_step . |
|
33 |
||
34 |
values "{map t [''x'',''y'',''z''] |t. |
|
44923 | 35 |
(\<lambda>p. SKIP) \<turnstile> (CALL ''p'', <''x'' := 42, ''y'' := 43>) \<Rightarrow> t}" |
43158 | 36 |
|
44923 | 37 |
values "{map t [''x'',''y'',''z''] |t. (\<lambda>p. SKIP) \<turnstile> (test_com, <>) \<Rightarrow> t}" |
43158 | 38 |
|
39 |
end |