Theory Procs_Stat_Vars_Dyn

theory Procs_Stat_Vars_Dyn
imports Procs
theory Procs_Stat_Vars_Dyn imports Procs
begin

subsubsection "Static Scoping of Procedures, Dynamic of Variables"

type_synonym penv = "(pname × com) list"

inductive
big_step :: "penv => com × state => state => bool" ("_ \<turnstile> _ => _" [60,0,60] 55)
where
Skip: "pe \<turnstile> (SKIP,s) => s" |
Assign: "pe \<turnstile> (x ::= a,s) => s(x := aval a s)" |
Seq: "[| pe \<turnstile> (c1,s1) => s2; pe \<turnstile> (c2,s2) => s3 |] ==>
pe \<turnstile> (c1;;c2, s1) => s3"
|

IfTrue: "[| bval b s; pe \<turnstile> (c1,s) => t |] ==>
pe \<turnstile> (IF b THEN c1 ELSE c2, s) => t"
|
IfFalse: "[| ¬bval b s; pe \<turnstile> (c2,s) => t |] ==>
pe \<turnstile> (IF b THEN c1 ELSE c2, s) => t"
|

WhileFalse: "¬bval b s ==> pe \<turnstile> (WHILE b DO c,s) => s" |
WhileTrue:
"[| bval b s1; pe \<turnstile> (c,s1) => s2; pe \<turnstile> (WHILE b DO c, s2) => s3 |] ==>
pe \<turnstile> (WHILE b DO c, s1) => s3"
|

Var: "pe \<turnstile> (c,s) => t ==> pe \<turnstile> ({VAR x; c}, s) => t(x := s x)" |

Call1: "(p,c)#pe \<turnstile> (c, s) => t ==> (p,c)#pe \<turnstile> (CALL p, s) => t" |
Call2: "[| p' ≠ p; pe \<turnstile> (CALL p, s) => t |] ==>
(p',c)#pe \<turnstile> (CALL p, s) => t"
|

Proc: "(p,cp)#pe \<turnstile> (c,s) => t ==> pe \<turnstile> ({PROC p = cp; c}, s) => t"

code_pred big_step .

values "{map t [''x'', ''y''] |t. [] \<turnstile> (test_com, <>) => t}"

end